I'm writing a customized bootloader based on I2C communication. My bootloader code is sitting in the last flash page and erases all other flash pages. As a lot of TI driver function uses also some part from flash I can't use them. But I can use ROM functions and register access which I do to erase for example the flash pages.
FlashSectorErasePonter_t FuncPointer = (uint32_t (*)(uint32_t))(ROM_API_FLASH_TABLE[5]); uint32_t result = FuncPointer(PageAddress);
I realized that when I call this function the next I2C frame leads only to a Start Interrupt. The then expected Data and Stop Interrupts are not received. When not calling the ROM function, even replacing with a delay, doesn't lead to problems. As the bootloader hasen't anything else to do instead of doing the I2C communication after one command was executed, I don't use interrupt routines. I poll the status register:
uint32_t IntReg = HWREG(I2C0_BASE + I2C_O_SMIS); if (IntReg != 0) { uint32_t StatusReg = HWREG(I2C0_BASE + I2C_O_SSTAT); HWREG(I2C0_BASE + I2C_O_SICR) = I2C_SRIS_STOPRIS + I2C_SRIS_STARTRIS + I2C_SRIS_DATARIS; if (IntReg & I2C_SMIS_STARTMIS) { //Start Interrupt received. So enabled Data and Stop Interrupts HWREG(I2C0_BASE + I2C_O_SIMR) |= I2C_SIMR_STOPIM + I2C_SIMR_DATAIM; } else if (IntReg & I2C_SMIS_STOPMIS) { //Stop Interrupt received. Data- und Stop-Interrupts are not used anymore HWREG(I2C0_BASE + I2C_O_SIMR) = I2C_SIMR_STARTIM; } else if (IntReg & I2C_SMIS_DATAMIS) { //Data interrupt receivef if (StatusReg & I2C_SSTAT_TREQ) { //Master want to read data. Send a byte HWREG(I2C0_BASE + I2C_O_SDR) = 0xFF; } else if (StatusReg & I2C_SSTAT_RREQ) { //Master has written data. Read it uint8_t aByte = HWREG(I2C0_BASE + I2C_O_SDR); } } }
I should have mentioned that CC1352 is the I2C slave. Also all my trace logic and the working with my data is removed from the source code listing above. From the trace I see (as said) that the data interrupt is not comming. I'm quite sure that the Master really wants to make a correct frame. But then it cannot happen, that I detect only the start condition but no data condition. Or am I wrong?
Regards
Erwin