S32K358 CAN RTD Watermark

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K358 CAN RTD Watermark

Jump to solution
2,448 Views
Greavesinator85
Contributor III

I'm trying to use the FlexCAN_Ip RTD drivers for an efficient CAN receive loop. I've been able to do this with FreeRTOS, using interrupt mode and enhanced RX. In this mode, I configure watermark to be 8, but in my FlexCAN_UserCallback only FLEXCAN_EVENT_ENHANCED_RXFIFO_COMPLETE fires, and if I do not add a call to FlexCAN_Ip_RxFifo when this happens, no more interrupts fire. 

 

How am I meant to use watermark mode? Is it only available with DMA?

0 Kudos
Reply
1 Solution
2,380 Views
Greavesinator85
Contributor III

I now have this working. The qualifiers around the buffer was key to avoid the corruption;

__attribute__(( aligned(32) )) static Flexcan_Ip_MsgBuffType gEnhancedRxFifoBuffer[ENHANCED_RXFIFO_WATERMARK] __attribute__ ((section (".mcal_bss_no_cacheable")));

 

Thanks for all your help!

View solution in original post

6 Replies
2,381 Views
Greavesinator85
Contributor III

I now have this working. The qualifiers around the buffer was key to avoid the corruption;

__attribute__(( aligned(32) )) static Flexcan_Ip_MsgBuffType gEnhancedRxFifoBuffer[ENHANCED_RXFIFO_WATERMARK] __attribute__ ((section (".mcal_bss_no_cacheable")));

 

Thanks for all your help!

2,387 Views
Greavesinator85
Contributor III

Apologies for the spam, I'm just actively debugging this. Setting FlexCAN_Ip_RxFifo before FlexCAN_Ip_SetStartMode has solved the EDMA->ES is set to SBE_1 error. Now I am investigating why the buffer is not holding the correct data. I'm sending ID 0x200 with 64 bytes counting up. I see some of this counting data but it is in chunks and can be missing large pieces, generally looks corrupted, and the address ID is always 0

0 Kudos
Reply
2,387 Views
Greavesinator85
Contributor III

Looks like after FlexCAN_Ip_SetStartMode, EDMA->ES is set to SBE_1

0 Kudos
Reply
2,387 Views
Greavesinator85
Contributor III

Ok, I have the DMA working in my application, thanks for your help. The example pointed me to Dma_Mux_IP_init which I was missing.

Now I do get the interrupt when it works, the first call to FlexCAN_Ip_RxFifo may pass or fail, but everything is smooth beyond that. This failure is at Static_Dma_Ip_GetLogicChannelError inside Dma_Ip_SetLogicChannelTransferList. I am using FreeRTOS as mentioned, any idea why this might be occurring? LocChState->LogicChErrors is returning 0x80000002

Also, I'm testing with 1 buffer, but the data seems corrupt, i.e. the ID is never correct

0 Kudos
Reply
2,421 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @Greavesinator85,

RTD driver is written in a way you need to call FlexCAN_Ip_RxFifo first, an interrupt is called once there is at least 1 message in the RXFIFO, driver reads single message from RXFIFO, and user has to call FlexCAN_Ip_RxFifo to enable interrupt again.

This was previously discussed with a colleague in this community post: Solved: S32K344 Using FlexCAN with RX FIFO and Interrupts - NXP Community.

You can refer to the routine below for enhanced RXFIFO configuration with watermark: Example S32K344 FlexCAN_Ip TX/RX/EnhanceRXFIFO DMA test S32DS3.5 RTD400 - NXP Community. It does also configure DMA, though.

Best regards,
Julián

0 Kudos
Reply
2,394 Views
Greavesinator85
Contributor III

Ok, so interrupt mode is working as expected in my case, where there is no way to use the watermark feature, as FlexCAN_Ip_RxFifo must be called on each interrupt. At max can speeds I see my RXTask taking up to 20% CPU time which is not acceptable.

 

I will try to use the example. I have refreshed it with my RTD 6.0.0 but I do not see any interrupts firing, I will investigate. I also see Rm_Init is not found?

I will look into DMA today to see if it can offer improvements. I am still unclear, will DMA only notify me once my watermark of messages  (8) is received?

0 Kudos
Reply