CAN RX mailbox support on STM32

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
trainman419
Posts: 4
Joined: Sat Jul 11, 2015 5:28 am

CAN RX mailbox support on STM32

Post by trainman419 »

Trying to read from CAN RX mailbox 1 (the second mailbox) results in an OS exception (I think; I'm new to Chibi and the board I'm using it on doesn't have a lot of IO to tell me what's wrong).

I'm using ChibiOS 3.0.0b5

I'm using an STM32F405, for which CAN_RX_MAILBOXES is defined to be 2

Reading through can_lld_receive for the STM32 (os/hal/ports/STM32/LLD/can_lld.c), it looks like I should be passing a mailbox ID of `2` in order to read mailbox 1 (0 is ANY, 1 is mailbox 0, and 2 is mailbox 1 on this chip).

In canReceive (os/hal/src/can.c), there is an assertion: `mailbox < (canmbx_t)CAN_RX_MAILBOXES` ; obviously this fails if I pass `2` as the desired mailbox.

I've updated the assertion on my copy of ChibiOS to be `mailbox <= (canmbx_t)CAN_RX_MAILBOXES`, and it works. (I'm also using the CAN filters to assign messages to mailbox 0 or 1 depending on their ID).
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: CAN RX mailbox support on STM32

Post by Giovanni »

Hi,

Thanks for finding. I will commit the change.

Giovanni
Post Reply