Announcement

Collapse
No announcement yet.

How to get spi1_WriteBlock to send bytes not words

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to get spi1_WriteBlock to send bytes not words

    I'm trying to use spi1_WriteBlock like so:

    var txPacket[20];

    txPacket[0] := 1;
    txPacket[1] := 2;
    txPacket[2] := 3;

    spi1_WriteBlock( str_Ptr(txPacket), 20 ); <- This sends 1, 0, 2, 0, 3, 0 ...

    I also tried:
    spi1_WriteBlock( &txPacket[0], 20 ); <- This compiles OK but doesn't work at all

    Also tried this:
    spi1_WriteBlock( txPacket, 20 ); <- This also compiles OK, but also does not work at all.

    There should be a way to send individual bytes from a buffer (especially on an SPI bus) right?
    What am I doing wrong?

  • #2
    BTW the port is initialized to 8 but mode
    SPI1_Init( SPI_SPEED13, SPI8_MODE_0 );

    Comment


    • #3
      Variables are 16bit in little endian order so my guess is that you are sending both 1/2's of the variable in 2 8 bit bytes. Since you have set the LObyte but not the HIbyte which is still 0, thus the 0's between your anticipated result. Someone more versed than I will have to say if WriteBlock can send only the LObyte.

      Comment

      Working...
      X