Hi, a SW rookie here.
Since I want to feed a driver's watchdog in 200ms by SPI, I decide to put the SPI transfer in a LPTMR IRQ. However, it doesn't work and debug into fault or PC doesn't receive any SPI frames. The partial code is as blow:
void LPTMR0_IRQHandler (void)
{
if(0!=(LPTMR0->CSR & LPTMR_CSR_TCF_MASK))
{
/* Check if TCF flag is set */
LPTMR0->CSR |= LPTMR_CSR_TCF_MASK;
/*Clear TCF flag by writting a logic one */
// PTD->PTOR |= 1<<0; /* Toggle Blue led */
PTE->PTOR |= 1 << 2;
printf("SPI Frame Sending! \n\r");
LPSPI0_transmit_16bits(tx_16bits);
LPSPI0_16bits_read = LPSPI0_receive_16bits();
// Drv_Dog_Feed();
// LPSPI0_IRQHandler ();
printf("SPI Frame Sended! \n\r");
}
The same way to send SPI frames in a RTOS 100ms task also doesn't work.
I think the reasons may be the interrupt priority or other causes.
Could someone tell me the bug in my code or how to make a period SPI watchdog-feeding in a IRQ or other places instead of in the main loop?
I forgot to initialize SPI. After I insert the initial code, now I can receive the SPI frames.
SO it is possible to do SPI transfer in a LPTMR IRQ. Now I can try to feed the dog in the IRQ, which is very convenient.