Hello
I'm currently trying to use a TMS470MF06607 as a SPI slave but am having problems with the TMS not responding to the SPI bus unless it has just been programmed.
While initially I saw the problem on a custom board, I have managed to recreated the problem using a Hercules TMS470M HDK with minimal changes to a basic HALCoGen project. In my HALCoGen project I have enabled only the RTI, HET and SPI1 drivers with each driver configured as:
RTI - Compare 0 period is set to 500ms. VIM channel 4 is enabled and set to ISR.
HET - Pins 0-5 set as output, odd pins set to output on their respective pins rather than read the even pins.
SPI1 - Master mode and Internal Clock turned off
- SCS[0], SOMI, SIMO and CLK pins set to SPI, others set to GIO
- SOMI set to output
- SIMO, CLK and SCS[0] set to input
- Data Format 0 set to baudrate of 20000 kHz, Charlen of 8, Clock Phase set (Matching the SPI master device)
- Transfer Group 0 set to CS_0, buffer length of 1, TRG_ALWAYS, TRG_DISABLED, Oneshot
- VIM channels 15 (MIBSPI1 Level 0) and 16 (MIBSPI1 Level 1) enabled, connected to ISR
The PLL parameters have been changed to set give a Pll Freq of 100MHz, thus VCLK1 is 100MHz
Looks like:
void main(void) { int temp,delay=0x200000; hetInit(); spiInit(); rtiInit(); rtiEnableNotification(rtiNOTIFICATION_COMPARE0); rtiStartCounter(0); spiEnableGroupNotification(spiREG1,0,1); spiSetData(spiREG1, 0, &spiRecData); spiTransfer(spiREG1, 0); while(1) { // Output number received over SPI to LEDs attached to HET[0..3] hetREG1->DOUT &= ~(0xF); hetREG1->DOUT |= (0xF & spiRecData); // Match LED on HET4 to HET5 hetREG1->DOUT &= ~(0x1 << 4); hetREG1->DOUT |= ((hetREG->DOUT & (0x1 << 5)) >> 1); // Simple Delay for(temp=0;temp<delay;temp++); }
spiRecData is a static uint16 defined in the top user code section of sys_main.c.
The following Notification handlers are defined:
void rtiNotification(uint32 notification) { if(notification == rtiNOTIFICATION_COMPARE0) { hetREG->DOUT ^= (0x1 << 5); } } void spiGroupNotification(spiBASE_t *spi, uint32 group) { switch(group) { case 0: spiGetData(spi,0,&spiRecData); spiSetData(spi,0,&spiRecData); spiTransfer(spi, 0); break; default: break; } }
This code will run fine if I program the device via CCS and disconnect the CCS debugger, the HET5 LED flashes due to the 500ms rti interrupt, the while loop in main matches it on the HET4 LED, and HET0-3 display the correct bit pattern for the number sent over SPI to the TMS470M (and the master can see the returned value as set in the spiGroupNotification handler).
The problem occurs when the board is power cycled, in this case I can see the interrupts are running and that the while loop in main is running by the LEDs on HET4 and HET5 flashing away, but the TMS never responds changes the LED patter on HET0 to HET3 or respond to the SPI master - has anyone run a TMS470M successfully as a SPI slave, or can point me to what is wrong?
Thanks
Mark