CAN interface for Stellaris Launchpad

The ARM Cortex M4 controller on the Stellaris Launchpad includes a CAN module. The microcontroller can't be connected directly to a CAN bus, a CAN bus transceiver is needed. This page shows how to interface the board to a CAN bus.

Hardware

There are a couple of CAN bus transceivers from different manufactures. I used the MCP2551 from Microchip which works on 5V. Because most controller pins (including the used CAN pins) are 5V tolerant, this is no problem and the chip can be directly connected.
MCP2551 CAN interface for Launchpad

Firmware

I followed the steps on the tutorial "Getting Started with the TI Stellaris LaunchPad on Linux" to install the gcc toolchain, the flash utility and the Stellarisware which includes several demo applications. There is also an example for transmitting CAN packets (examples/peripherals/can/simple_tx.c). There are only a few modifications to adopt it to the Launchpad.
Set the clock option (perhaps the original settings in the example also works, I have not tried):
SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
            
Map the CAN0 module to PORTE PE4 and PE5:
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
GPIOPinConfigure(GPIO_PE4_CAN0RX);
GPIOPinConfigure(GPIO_PE5_CAN0TX);
GPIOPinTypeCAN(GPIO_PORTE_BASE, GPIO_PIN_4 | GPIO_PIN_5);
SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN0);
            

Test

After flashing the binary file to the controller, I tested it with an USBtin, the simple USB to CAN interface on the CAN bus. Just changed the baudrate of USBtin to 500kBaud to match with the configured transmitting speed of the Launchpad and it worked! Breadboard with CAN transceiver for Stellaris Launchpad

Links

en TI's Stellaris Launchpad