Other Parts Discussed in Thread: SYSBIOS
Hardware: c6655 custom board
1. If the SPI driver is linked with firmware NOT using Sysbios, it always works.
2. If the same SPI driver is linked with firmware using Sysbios,
i) Set project Debug option "Auto Run and Launch Options -> Run to symbol" as "c_int00".
ii) Connect the debugger to the target board and load the firmware and run, SPI failed.
iii) Re-load the firmware and run, SPI failed.
iv) Repeat step iii) multiple times, it always failed.
v) Re-load the firmware, add a breakpoint at Main(). run to Main(). Re-load the firmware again, remove the breakpoint and run, this time SPI worked.
Below are the SPI register dump and SPI configuration of working and failing scenario.
SPI working scenario --
SPI register dump before config...
0x20bf0000: 0x00000000, 0x00000000, 0x00000000, 0x00000000
0x20bf0010: 0x01000000, 0x00000000, 0x00000000, 0x00000103
0x20bf0020: 0x00000000, 0x00000000, 0x00000000, 0x00000000
0x20bf0030: 0x01010f03, 0x00000000, 0x00000000, 0x00000000
0x20bf0040: 0x80000000, 0x80000000, 0x00000000, 0x00000003
0x20bf0050: 0x00000000, 0x00000000, 0x00000000, 0x00000000
0x20bf0060: 0x00000000, 0x00000000, 0x00000000, 0x00000000
0x20bf0070: 0x00000000, 0x00000000, 0x00000000, 0x00000000
Config SPI with...
SPI_SPIGCR0 = 0x00000000
SPI_SPIGCR0 = 0x00000001
SPI_SPIGCR1 = 0x00000003
SPI_SPIPC0 = 0x00000e03
SPI_SPIFMT0 = 0x00020308
SPI_SPIFMT1 = 0x00020608
SPI_SPIFMT2 = 0x00020610
SPI_SPIDEF = 0x00000003
SPI_SPIINT0 = 0x00000000
SPI_SPILVL = 0x00000000
SPI register dump after config...
0x20bf0000: 0x00000001, 0x00000003, 0x00000000, 0x00000000
0x20bf0010: 0x01000000, 0x01010e03, 0x00000000, 0x00000303
0x20bf0020: 0x00000000, 0x00000000, 0x00000000, 0x00000000
0x20bf0030: 0x01010f03, 0x00000000, 0x00000000, 0x00000000
0x20bf0040: 0x80000000, 0x80000000, 0x00000000, 0x00000003
0x20bf0050: 0x00020308, 0x00020608, 0x00020610, 0x00000000
0x20bf0060: 0x00000000, 0x00000000, 0x00000000, 0x00000000
0x20bf0070: 0x00000000, 0x00000000, 0x00000000, 0x00000000
SPI Enabling...
SPI_SPIGCR1 = 0x01000003
SPI register dump after SPI enabled...
0x20bf0000: 0x00000001, 0x01000003, 0x00000000, 0x00000000
0x20bf0010: 0x01000200, 0x01010e03, 0x00000000, 0x00000303
0x20bf0020: 0x00000000, 0x00000000, 0x00000000, 0x00000000
0x20bf0030: 0x01010f03, 0x00000000, 0x00000000, 0x00000000
0x20bf0040: 0x80000000, 0x80000000, 0x00000000, 0x00000003
0x20bf0050: 0x00020308, 0x00020608, 0x00020610, 0x00000000
0x20bf0060: 0x00000000, 0x00000000, 0x00000000, 0x00000000
0x20bf0070: 0x00000000, 0x00000000, 0x00000000, 0x00000000
SPI failing scenario --
SPI register dump before config...
0x20bf0000: 0x00000000, 0x00000000, 0x00000000, 0x00000000
0x20bf0010: 0x01000000, 0x00000000, 0x00000000, 0x00000103
0x20bf0020: 0x00000000, 0x00000000, 0x00000000, 0x00000000
0x20bf0030: 0x01010f03, 0x00000000, 0x00000000, 0x00000000
0x20bf0040: 0x80000000, 0x80000000, 0x00000000, 0x00000003
0x20bf0050: 0x00000000, 0x00000000, 0x00000000, 0x00000000
0x20bf0060: 0x00000000, 0x00000000, 0x00000000, 0x00000000
0x20bf0070: 0x00000000, 0x00000000, 0x00000000, 0x00000000
Config SPI with...
SPI_SPIGCR0 = 0x00000000
SPI_SPIGCR0 = 0x00000001
SPI_SPIGCR1 = 0x00000003
SPI_SPIPC0 = 0x00000e03
SPI_SPIFMT0 = 0x00020308
SPI_SPIFMT1 = 0x00020608
SPI_SPIFMT2 = 0x00020610
SPI_SPIDEF = 0x00000003
SPI_SPIINT0 = 0x00000000
SPI_SPILVL = 0x00000000
SPI register dump after config...
0x20bf0000: 0x00000001, 0x00000003, 0x00000000, 0x00000000
0x20bf0010: 0x01000000, 0x00000e03, 0x00000000, 0x00000103
0x20bf0020: 0x00000000, 0x00000000, 0x00000000, 0x00000000
0x20bf0030: 0x01010f03, 0x00000000, 0x00000000, 0x00000000
0x20bf0040: 0x80000000, 0x80000000, 0x00000000, 0x00000003
0x20bf0050: 0x00020308, 0x00020608, 0x00020610, 0x00000000
0x20bf0060: 0x00000000, 0x00000000, 0x00000000, 0x00000000
0x20bf0070: 0x00000000, 0x00000000, 0x00000000, 0x00000000
SPI Enabling...
SPI_SPIGCR1 = 0x01000003
SPI register dump after SPI enabled...
0x20bf0000: 0x00000001, 0x01000003, 0x00000000, 0x00000000
0x20bf0010: 0x01000000, 0x00000e03, 0x00000000, 0x00000103
0x20bf0020: 0x00000000, 0x00000000, 0x00000000, 0x00000000
0x20bf0030: 0x01010f03, 0x00000000, 0x00000000, 0x00000000
0x20bf0040: 0x80000000, 0x80000000, 0x00000000, 0x00000003
0x20bf0050: 0x00020308, 0x00020608, 0x00020610, 0x00000000
0x20bf0060: 0x00000000, 0x00000000, 0x00000000, 0x00000000
0x20bf0070: 0x00000000, 0x00000000, 0x00000000, 0x00000000
Observed that the reserved bits of SPIPC0(0x20bf0014) and reserved register 0x20bf001c are different between the two scenarios. After SPI is enabled with SPI_SPIGCR1 = 0x01000003, TXINTFLG of SPIFLG changed to 1 in the working scenario but remained 0 in the failing scenario. Just wondering if the undocumented reserved bits world provide extra debug information.