Calling Card

STM32 CAN Transmit Frame Exercise

Task

At power-up, send one hello frame on CAN1: standard ID 0x700 plus the node ID, two data bytes, 02 then 07. Send it once. The registers and bit fields are on the Datasheet tab.

Circuit

Block diagram: SW1, a four-position node ID switch, drives PA0 to PA3 of U1, an STM32F4; U1 drives CAN TX on PA12 and reads CAN RX on PA11 through U2, a CAN transceiver, onto the CANH and CANL bus with a 120 ohm terminator R1 and R2 at each end, watched by TP1, a CAN analyzer

Pass condition

The analyzer on the bus records exactly one frame, as figure 2 shows for node 5. Your program confirms each mode change it asks for in MSR and ends in normal mode.

Expected output for node 5: the CAN analyzer records one standard frame, ID 0x705, DLC 2, data 02 07, and nothing else

Notes

node_id() is given. It returns switch SW1's setting, 1 to 15. The bench sets SW1 before power-up. Bus at 500 kbit/s: CAN1_BTR = 0x00050003. No clock enable is needed.

Related challenges

Loading the interactive arena.