Get yourself a board with CAN interfaces, preferably two.
You need a receiving device to acknowledge data being sent. Like
emilio (Community Member)
Edited by ST Community July 21, 2018 at 5:48 PM Posted on November 30, 2014 at 23:36
Thanks for answering me.
I think I'll use two STM32 Nucleo boards in order to implement a CAN transmitter and a CAN receiver.
The example seems very useful, I'll post here later if I have any dubt! 🙂
Like
dteal (Community Member)
Edited by ST Community July 21, 2018 at 5:48 PM Posted on February 08, 2015 at 21:40
Clive1,
I too am new to the CAN bus code but have spent the last few days looking over examples and searching the web for tips. I copied your sample code from the RedDragon 407 and will be comparing it closely with my code (which came from the ST examples and use the StdPeriph library.
I'm just trying to get transmit to work, so my question is this: shouldn't I see at least some o-scope activity on the CANH or CANL signals on the bus side of the transceiver? I'm using the STM32303C-EVAL unit and everything else seems fine. I also have a Microchip CAN bus analyzer that can receive as well as transmit - I can see signals from it in transmit mode (and not connected to any peer).
Thanks for your help.
DT
Like
Tesla DeLorean (Community Member)
Edited by ST Community July 21, 2018 at 5:48 PM Posted on February 09, 2015 at 03:35
[DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx? RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Discovery/Basic%20CAN%20bus%20transmit&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580 0084C20D8867EAD444A5987D47BE638E0F&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/AllItems.aspx¤tviews=1]Other Thread
I haven't tinkered with this F3 board, the lack of two boards, or two buses, is going to make it difficult to test or evaluate. Generally you need some CAN device to receive the transmissions.
You might want to check the Loop Back modes, and if those do, or do not generate CAN_TX, and CAN_H and CAN_L signals.
Like
dteal (Community Member)
Edited by ST Community July 21, 2018 at 5:48 PM Posted on February 09, 2015 at 23:34
Thanks Clive. I got it to work and can see pulses on the CAN transceiver with nothing else attached to the bus. The problem was that I was using GPIO_AF_9 instead of GPIO_AF_7. I can transmit and receive (using the Microchip bus analyzer in transmit mode) at 1 Mbps!
I do have one more questions that applies to coding style: in order to get the receive to work I had to comment out this function in stm32f30x_it.c:
void USB_LP_CAN1_RX0_IRQHandler(void)
and then add it to my main.c (and my supporting code) to extract the received data. That seems dangerous if ST: is going to update those files in the future, my code will break. Is there another, more elegant approach to this?
Thanks,
DT
Like
Tesla DeLorean (Community Member)
Edited by ST Community July 21, 2018 at 5:48 PM Posted on February 10, 2015 at 00:35
Well the stm32f3xx_it.c file is project specific so no one is going to change it on you. I tend to present examples that work as a single monolithic file as this significantly improves the clarity, and reduces the ''why doesn't this compile'' type responses.
Once you are comfortable playing with the project templates provided by ST, you can certainly adapt or adjust to your own style or the one an existing you're porting to the platform. Most of the interrupt vectors have a weakly linked routine in the startup_stm32f3xx.s file, so you can choose where and if you want to provide the body function for them.