Processor Expert, MSCAN, and transmit buffer priority

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

Processor Expert, MSCAN, and transmit buffer priority

975 Views
Potatoswatter
Contributor I

I want to send a block of data through a sequence of CAN messages using the Processor Expert driver. I don't want the sequence to defer any other messages that might need transmission in the meantime.

 

The MSCAN controller has a priority value for each transmission buffer, but the Processor Expert driver does not support prioritization. Instead it sets every message to highest priority. MSCAN does secondary prioritization if all buffers are set to equal priority, with buffer 0 over 1 over 2. So, I use buffer 0 for non-sequence messages and 1 and 2 for double-buffered transmission.

 

There's just one problem. How do I ensure that buffer 2 is sent before buffer 1 when reloading buffer 1? For example, if buffer 2 contains the next message to send, and I get the tx interrupt because buffer 1 was just transmitted, how do I ensure that SendFrame inside the ISR won't cause the new buffer 1 to race past buffer 2?

If PE only ignored the priority register (TBPR) or set it to a high value, then there would be no problem. It seems the overzealousness is a defect in the driver.

Labels (1)
0 Kudos
2 Replies

479 Views
ProcessorExpert
Senior Contributor III

Hello,

we are sorry for the inconvenience but your requested functionality is not currently supported by CAN component. As you can see in the code of SendFrame method it sets the CANTTBPR register to highest priority always. To workaround the problem you have to disable code generation of this component through “Don´t Write Generated Component Modules“ from component´s pop-up menu and extend its functionality manually (see SendFrame.png). Please also find enclosed example project where is the SendFrame method extended of a additional Prior parameter to allow specify transmit buffer priority in the user code.

I have passed this request to developers to consider to support it for CW V10.2.

 

best regards
Vojtech Filip
Processor Expert Support Team

0 Kudos

479 Views
Potatoswatter
Contributor I

Thank you!

 

Note that the extra argument is overkill to fix the problem. It is sufficient to set the priority to a low value (high numeric value) inside SendFrame, and then allow the user to increase it once the function has returned. In my case, I wouldn't increase it until just before the next call to SendFrame.

 

I don't know if this change would affect existing Processor Expert code if included in an update, but it's quite likely it wouldn't.

 

0 Kudos