This directory contains assembly language examples related to CAN.
This examples uses two stm32 boards and two CAN transceivers to enable the transmission of data from the controller, can-c.s to the peripheral, can-p.s.
$ make can-c.elf can-p.elf
Connect the USB micro cable to the STM32 ST-LINK port on the board that is going to be used as the peripheral.
Start openocd:
$ make openocd
Start a telnet session:
$ telnet localhost 4444
Flash the program:
> reset halt
> flash write_image erase can-p.elf.hex
> reset run
Connect the USB micro cable to the STM32 ST-LINK port on the board that is going to be used as the controller.
Start openocd:
$ make openocd
Start a telnet session:
$ telnet localhost 4444
Flash the program:
> reset halt
> flash write_image erase can-c.elf.hex
> reset run
Start minicom
:
$ minicom --baudrate 115200 --device /dev/ttyUSB0
Next press the reset button on the controller board and 'A7' should be displayed in minicom. The A is the data sent to the CAN bus and 7 is the identifier of the CAN frame.
This example can be run without any external transceiver or wires connected (wires for CAN that is) and use the CAN loopback to send and receive data. The received data is then sent using UART so that it can be inspected using minicom.
$ make can-loopback.elf
First start openocd:
$ make openocd
Start a telnet session:
$ telnet localhost 4444
Flash the program:
> reset halt
> flash write_image erase can-loopback.elf.hex
Start minicom
:
$ minicom --baudrate 115200 --device /dev/ttyUSB0
Next press the reset button and 'A7' should be displayed in minicom. The A is the data sent to the CAN bus and 7 is the identifier of the CAN frame.