S32k144 CAN0 intterupt

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

S32k144 CAN0 intterupt

799 次查看
edt102983
Contributor I

Hi, I want to use a interrupt to do CAN_ReceiveBlocking when CAN bus receiving a message; in other words, i want to write CAN_ReceiveBlocking in interrupt handler.

I have tried initing following two and the recv_ISR is showing below:

INT_SYS_InstallHandler(CAN0_ORed_0_15_MB_IRQn, &recv_ISR, NULL);
INT_SYS_EnableIRQ(CAN0_ORed_0_15_MB_IRQn);

void recv_ISR(void)
{
uint8_t i;
uint32_t rx_id= 0x155;
int rtn;

can_message_t rx_message = {
.cs = 0U,
.id = rx_id,
.length = 8};

rtn=CAN_ReceiveBlocking(&can_pal0_instance, 1, &rx_message, TIMEOUT);

if (rtn==0){
printf("CAN0_RX success ID=0x%x Data=[",rx_message.id);
for(i=0; i<8; i++ ){
printf("0x%x ",rx_message.data[i]);
}
printf("]\n");
}

else printf("CAN0_RX error.rtn=%d\n=",rtn);

}

 

but it doesn't work, can give me some instruction?

0 项奖励
回复
1 回复

784 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Hiedt102983,

CAN_ReceiveBlocking receives a CAN frame using the specified buffer, in a blocking manner.

CAN_ReceiveBlocking in a blocking manner.jpg
If you want to receive CAN frame by interrupt, please refer: S32K1xx SDK FlexCAN sample projects to demonstrate its basic and advanced features

Best Regards,
Robin
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 项奖励
回复