I am wondering if anyone is familiar with any STM32f10x micro-controllers?
If so, I am having some problems configuring a CAN driver. I can run the demo code, which is set to a loop_Back mode, but I cannot get Normal_Mode to work.
I read through all the data sheets, and everything is configured correctly except the INAK in the CAN_MSR register never resets to 0. I can provide more detail if needed, but first I need to know if there is someone who has worked with a STM32F103 microcontroller and CAN messages.
You set the Tx pin as Out_PP, but it should be configured as Alternate Function instead. Below is my init code for CAN on an STM32F107. I copy-pasted and stripped it from an existing project so some stuff is not needed (like not all GPIOs need to be enabled). Also note I used the remap function to put the CAN Rx and Tx pins on port D.
This configuration sets the bus speed to 500 kbit/s when using a 72 MHz clock.
Sending a message can then be done like this:
Receiving is done via IRQ:
I've worked with STM32F103 microcontrollers but my only (small) experience with CAN was that enabling it caused USB not to work. The two modules share a memory space. So make sure you disable the USB module and the clock to it (clear bit 23 of RCC_APB1ENR).