Hi,
I have K60 tower. I tried example code in the folder Freescale_MQX_4_2\mqx\examples\spi_legacy
I have three issues:
1. in spi.c code, I have to comment out the following code snippet:
| if (SPI_OK == ioctl (spifd, IO_IOCTL_SPI_GET_STATS, &stats)) { | // Get statistics |
printf ("Interrupts: %d\n", stats.INTERRUPTS);
printf ("Rx packets: %d\n", stats.RX_PACKETS);
printf ("Rx overflow: %d\n", stats.RX_OVERFLOWS);
printf ("Tx packets: %d\n", stats.TX_PACKETS);
printf ("Tx aborts : %d\n", stats.TX_ABORTS);
printf ("Tx underflow: %d\n", stats.TX_UNDERFLOWS);
}
because the stats structure doesn't include INTERRUPTS, RX_OVERFLOWS, TX_ABORTS, and TX_UNDERFLOWS.
After commented out, it runs. I have SPI0 channel enabled. Program runs with Write Returns successfully, and Read Back as 0's.
2.
Read memory status ... 0x00
Enable write latch in memory ... OK
Read memory status ... 0x00
Write unprotect memory ... OK
Enable write latch in memory ... OK
Read memory status ... 0x00
Erase whole memory chip:
Read memory status ... 0x00
Erase chip ...OK
Enable write latch in memory ... OK
Read memory status ... 0x00
Write byte to location 0x00100000 in memory ... [0xBA]
Read memory status ... 0x00
Read byte from location 0x00100000 in memory ... [0x00]
Writing [Hello,World!]
Enable write latch in memory ... OK
Read memory status ... 0x00
Page write 12 bytes to location 0x001001f0 in memory:
Hello,World!
Read memory status ... 0x00
Reading 12 bytes from location 0x001001f0 in memory:
Read [] -- Error Here --- it shall read back Hello,World!, instead of empty string
Enable write latch in memory ... OK
Read memory status ... 0x00
Page write 16 bytes to location 0x001002f0 in memory:
ABCDEFGHIJKLMNOP
Enable write latch in memory ... OK
Read memory status ... 0x00
Page write 56 bytes to location 0x00100300 in memory:
QRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz1234567890
Read memory status ... 0x00
Reading 72 bytes from location 0x001002f0 in memory:
IO_IOCTL_SPI_READ_WRITE ... OK
Simultaneous write and read - memory read from 0x00100000 (10):
Write: 0x03 0x10 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
Read : 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
Simultaneous read/write (data == 0x00) ... ERROR
3. In Interrupt Mode, according to the readme.pdf in the spi_legacy folder, BSPCFG_ENABLE_ISPI0 macros must be set to non-zero in the user_config.h
I have problems with BSPCFG_ENABLE_ISPI0. The parameter is not defined in the user_config.h file, if I added a line after #define BSPCFG_ENABLE_SPI0 1
#define BSPCFG_ENABLE_ISPI0 1
then it seems has problem with graphical view of the user_config.h, at least the BSPCFG_ENABLE_ISPI0 is not displayed.
Thank you,
David Zhou