[S32K]How to generate a SPI transfer in a LPTMR IRQ?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

[S32K]How to generate a SPI transfer in a LPTMR IRQ?

653 次查看
carlos_kan
Contributor II

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?

 

 

0 项奖励
回复
1 回复

638 次查看
carlos_kan
Contributor II

1.png

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.