Hi,
I'm trying to set my SPI0 to 16 bits through:
// Framesize = 16 | |
param = 16; | |
printf ("Changing the Framesize to %d bits ... ", param); | |
if (SPI_OK == ioctl (spifd, IO_IOCTL_SPI_SET_FRAMESIZE, ¶m)) | |
{ | |
printf ("OK\n"); | |
} | |
else | |
{ | |
printf ("ERROR\n"); | |
} |
The procedure is accepted and I receive an OK and read 16 when a GET_FRAMESIZE is issued.
The problem is I cannot write at the device; it always returns error, only with 16 bits, if 8 is set, it works fine.
How can I work with SPI in 16 bits?
Thank you...BrunoCastelucci
已解决! 转到解答。
Hi Sandro
Glad to hear you get it working.
Not sure, but the error might be because the fputc is intended for writing just one character (1 byte) to the stream.
Maybe you want to try using fputs instead, and sending a two-character string.
Let us know if that works.
Thanks
juan gutierrez
Hi Juan,
Thanks for replying.
I'm using MQX. Yes, the slave is 16 bits; it's an LCD display.
I'm using 'fputc(data, spifd)' to write the data and, when configured to 16 bits, I get an IO_ERROR (-1) and nothing happens on the SDA, SCL, lines.
The fputc() enables de CS to the device and 'fflush()' disables it.
I solved the problem by sending two bytes (2 x fputc()) and then 'fflush()', this way the CS is only disabled after 16 bits is transmitted.
Anyway, I think the SPI should work fine at 16 bits.
Thanks and regards.
Hi Sandro
Glad to hear you get it working.
Not sure, but the error might be because the fputc is intended for writing just one character (1 byte) to the stream.
Maybe you want to try using fputs instead, and sending a two-character string.
Let us know if that works.
Thanks
juan gutierrez
juangutierrez please review this case and provide follow up.