cancel
Showing results for 
Search instead for 
Did you mean: 

bxCAN has an unwanted pause between transmits

Disona
Associate II

Hello everyone!
I have a strange problem with bxCAN on ST32F427.


My bxCAN config:

  • i use CAN2 module
  • bxCAN is inited in normal mode, no sleep, no time-triggered transmission, automatic retransmission enabled
  • baudrate 125 kbps
  • transmit mailboxes 0 and 2 are used
  • TX finished ISR and RX ISR are enabled

 

CAN network and data flow config (hint - it's a CANopen protocol)

  • two devices in the network - ST32 and USB-CAN adapter, controlled by PC;
  • ST32 always sends 3 periodic messages (TPDO in CANopen) from Mailbox 0
    • ID 0x181 with 50 ms period (ID priority 0)
    • ID 0x281 with 50 ms period (ID priority 1)
    • ID 0x381 with 50 ms period (ID priority 2)
  • ST32 always sends 1 periodic message (Heartbeat in CANopen) from Mailbox 2
    • ID 0x701 with 1000 ms period (ID priority 5)
  • PC several times in a second sends 20 sequential messages, there is no pause between any of this 20 messages 
    • these 20 use ExtID, which is always 0x18064059. STID part of this ExtID is 0x601 (ID priority 4) - SDO request for ST32
  • ST32 answers (must answer) each of these messages 
    • answer ID is 0x581 (ID priority 3)

 

Answer mechanism: when ST32 receives a message from PC, RX ISR is triggered. In this ISR received message ID is analyzed and if an SDO-request is detected (ID is 0x601), ST32 immediatly puts an answer into Mailbox 2. Immediately means, that Mailbox is filled during this RX ISR.

 

So my problem: if i have two filled TX mailboxes, i expect two messages to be transmitted sequentially without any pause. During message "burst" from the PC i expect ST32 to win arbitration, because all of its messages have higher priority.

But what i see on the bus: if i have two TX mailboxes during the message burst from the PC, ST32 sends one of the messages, but then PC sends it's message. And after the first transmit ST32 doesn't even try to send the next one immediately. It sends it's second message only after PC's message.

 

How do i debug it: i've connected a Logical Analyzer to the ST32 and watch the following signals:

  • CAN RX and RX (2 signals)
  • CAN TX ISR and RX ISR duration (2 signals) 
  • PDO and SDO TX completed (in TX ISR) (2 signal)
  • Mailbox 0 Full and Mailbox 2 Full (2 signals)

"CAN TX/RX ISR" signals are GPIOs the are pulled up on ISR entry and pulled down on ISR exit.
"PDO and SDO TX completed" signals are GPIOs that are pulled up in TX ISR when the program finds out which mailbox caused the ISR and pulled down on ISR exit.
"Mailbox 0 Full and Mailbox 2 Full" signals are GPIOs that are up when a mailbox is full and down, when it's empty based on TME0 and TME2 bits' states. The bits' states are software polled with 10 kHz frequency (ISR from timer).

The screenshot is in the attachment.
THERE IS AN ERROR - "MAILBOX 2 Full" is captioned as "MB1 Full" - but it's MB0 (i've noticed that too late, sorry).

So please, could someone help me on this? I couldn't find any bits or settings in bxCAN for "pause between transmissions". What am i doing wrong?

3 REPLIES 3
mƎALLEm
ST Employee

Hello,

The issue is not clear!

The transmission of a message depends on the arbitration based on the ID sent vs other IDs sent by other nodes. Lower ID have the most priority to be transmitted on the bus. 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Hi!
Yes, you're right, BUT

Lower ID wins if arbitration process starts.

As i mention in my post and show on the waveforms, the arbitration process does not start.

It's just PC taking the bus without any arbitration with MCU because MCU for some reason doesn't start transmission.

Please take a look at the picture attached to the original post.

Disona
Associate II

TLDR:
I have two filled mailboxes. Both with TXRQ set. The first mailbox transmits it's message. THEN i expect second mailbox to start transmitting. Maybe it will win arbitration, maybe not, that's not the problem.

The problem is that MCU doesn't even start transmission in time and another node occupies the bus.