Hi,
i would ask if there's any example for CAN FD Interrupt without SDK.
I've configured IMASK1, is there anything else I must do?
I tested it with canoe and send a CAN FD Message. But it says Tx Error (Bit Error and NAK Error)
Hope anyone can help
Sandra
Solved! Go to Solution.
Hi@Sandra1
I made a demo base on "S32K144_Project_CanFd" which is provided in S32 DS For Arm V2.2.
1.set MB4 interrupt mask in FLEXCAN0_init()
CAN0->IMASK1 |= CAN_IMASK1_BUF31TO0M(1 << 4);/*Enable MB 4 interrupt mask*/
2.Set NVIC and install CAN0 IRQ Handler
void NVIC_init_IRQs (void)
{
S32_NVIC->ICPR[2] = 1 << (CAN0_ORed_0_15_MB_IRQn % 32);
S32_NVIC->ISER[2] = 1 << (CAN0_ORed_0_15_MB_IRQn % 32);
S32_NVIC->IP[CAN0_ORed_0_15_MB_IRQn] = 0xA0;
}
void CAN0_ORed_0_15_MB_IRQHandler(void)
{
if ((CAN0->IFLAG1 >> 4) & 1) { /* If CAN 0 MB 4 flag is set (received msg), read MB4 */
FLEXCAN0_receive_msg(); /* Read message */
rx_msg_count++; /* Increment receive msg counter */
if (rx_msg_count == 10) { /* If 1000 messages have been received, */
PTD->PTOR |= 1<<16; /* toggle output port D16 (Green LED) */
rx_msg_count = 0; /* and reset message counter */
}
FLEXCAN0_transmit_msg(); /* Transmit message using MB0 */
}
}
Hi@Sandra1
I made a demo base on "S32K144_Project_CanFd" which is provided in S32 DS For Arm V2.2.
1.set MB4 interrupt mask in FLEXCAN0_init()
CAN0->IMASK1 |= CAN_IMASK1_BUF31TO0M(1 << 4);/*Enable MB 4 interrupt mask*/
2.Set NVIC and install CAN0 IRQ Handler
void NVIC_init_IRQs (void)
{
S32_NVIC->ICPR[2] = 1 << (CAN0_ORed_0_15_MB_IRQn % 32);
S32_NVIC->ISER[2] = 1 << (CAN0_ORed_0_15_MB_IRQn % 32);
S32_NVIC->IP[CAN0_ORed_0_15_MB_IRQn] = 0xA0;
}
void CAN0_ORed_0_15_MB_IRQHandler(void)
{
if ((CAN0->IFLAG1 >> 4) & 1) { /* If CAN 0 MB 4 flag is set (received msg), read MB4 */
FLEXCAN0_receive_msg(); /* Read message */
rx_msg_count++; /* Increment receive msg counter */
if (rx_msg_count == 10) { /* If 1000 messages have been received, */
PTD->PTOR |= 1<<16; /* toggle output port D16 (Green LED) */
rx_msg_count = 0; /* and reset message counter */
}
FLEXCAN0_transmit_msg(); /* Transmit message using MB0 */
}
}