Hello,
I am using I2C slave mode on the TM4C123GH6PM, so an I2C master (a raspberry pi) can access an array of 32bytes, that is constantly calculated.
I noticed sometimes, that my slave devices returns all 255's. (an array of 32, containing all 255s)
I am using a number of timers, one of them updating at 10hz, the other 100hz, and a final led timer that updates at 2 to 5hz.
Not being able to debug the issue, I have started commenting out, different timers that I use, trying to find what causes it.
I finally found that it is the timer that I use for firing serial LED's, over SSI1. Namely:
I initialize with:
// initialize led driver MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1); MAP_GPIOPinConfigure(GPIO_PF2_SSI1CLK); MAP_GPIOPinConfigure(GPIO_PF1_SSI1TX); MAP_GPIOPinTypeSSI(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2); MAP_SSIConfigSetExpClk(SSI1_BASE, ui32SysClkFreq, SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 2400000, 8); MAP_SSIEnable(SSI1_BASE);
And the timer fires up the part: (15 times in a row)
#define SPILONG 0xE0 #define SPISHORT 0x40 void send_byte(unsigned char b) { unsigned char bit; for(bit = 0; bit < 8; bit++) { if(b & 0x80) { MAP_SSIDataPut(SSI1_BASE, SPILONG); } else { MAP_SSIDataPut(SSI1_BASE, SPISHORT); } b <<= 1; } }
Also, after calling the SSIDataPut(SS!_BASE, byte), to send the bytes I call:
while(MAP_SSIBusy(SSI1_BASE)) {}
So I have experimentally determined that, when the MAP_SSIDataPut(SSI1_BASE, SPILONG) is running, and if the tm4c123 slave device receives a read request, it will return all 255's.
I even changed the part I2CSlaveDataPut(I2C0_BASE, buffer[index++]) to I2CSlaveDataPut(I2C0_BASE, 1); - but when ever the 2 interrupts collide i2c slave device returns wrong data.
I
s there any way around this, or any reasons to why it is causing? They are different devices, I2C and SSI on the microcontroller, and even ports are different, so why could this be?
Best Regards,
Can A.