Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 7 months ago.
Can Bus on STM32F103C8T6 only work when USB plugged into computer host
I am trying to implement CAN bus on STM32F103C8T6 using this library:
Import programCAN_Hello
Using CAN bus with (not just NUCLEO) mbed boards
It's only working when i plugged the micro USB power to USB Computer. When i am trying to plug micro USB port to adaptor / USB Charger, it doesn't work. The sender only trying to transmit 3 message then show error 'Transmission error' and the receiver can't get the message. Also using 5V on Pin it's still not work. Also i am trying to use PB8 & PB9 it's not working at all. Thanks
1 Answer
6 years, 7 months ago.
Hello Arnas,
When you connect both boards to the same PC over USB cables then the grounds of these boards become connected one another. If you supply power for one of them from a USB charger then make sure that also in such case the grounds (GND) of STM32F103C8T6 boards are connected one another (for example using a flying wire).
I did this but still not work. What i thinking is CAN activate when USB is active (USB data pin establish). Unfortunately it's only working with pin PA11 & PA12.
posted by 09 Apr 2018I think it could be due to the design of some USB chargers when the USB_DP and USB_DM pins are connected one another inside the USB connector (like in this case). When such USB charger is used, since the USB_DP and USB_DM pins are connected to the PA_11, PA_12 pins, the CAN RD and CAN TD pins become connected one another and the CAN peripheral fails to operate. To avoid such short circuits try to connect the CAN peripheral to the PB_8, PB_9 pins and modify the program accordingly.
CAN can(PB_8, PB_9); // CAN Rx pin name, CAN Tx pin name
It worked for me when using a USB changer to supply power for the boards.
posted by 10 Apr 2018Finally i found the problem. So i am using cheap SN65HVD230 transceiver and it has different label pin on both PCB side! So the pin CAN L it connected to VCC and vice versa. What the weird the although it has wrong pins at all, its working, it able to send and receive the data. But not working 100%, like my problem above, so what i think before is the hardware is working and the wiring is right. Finally it's also working with pins PB_8 and PB_9. So many many thank you with your help. Btw did you already test for STM32F103VET6. I have to think to use it since the mbed output is bloated. It didn't fit on 128kb for CAN, USB and RTOS feature.
posted by 10 Apr 2018I'm glad that you have fixed the problem. Certainly, the STM32F103VET6 MCU offers a lot of features at a very good price. However, the online compiler supports only one MBED board with such MCU, the Seeed Arch Max board. I have recently published a STM32F407VET6 info page and also a few demos enabling to test the STM32F103VET6 black board using the online compiler:
https://os.mbed.com/users/hudakz/code/STM32F407VET6_Blinky_RTOS/
https://os.mbed.com/users/hudakz/code/STM32F407VET6_TCPSocket/
https://os.mbed.com/users/hudakz/code/STM32F407VET6_WebSwitch/
Unfortunately the Seed Arch Max neither supports CAN peripheral nor MBED OS-5. An alternative is to build programs for the DISCO-F407G board offline using MBEDs CLI tool which supports both CAN bus and MBED OS-5.
Yes, i also have the board STM32F407VET6. I'm using offline compiler (ARCH_MAX) but i am not able to use CAN. I don't think using DISCO-F407G board to support CAN since it only support MBED OS2, no? I never use online compiler since it take a lot of time for me to test trial and error. Is there any tutorial how to use mbed-dev?
posted by 10 Apr 2018- I have double checked it and it seems I was wrong. MBED does not support CAN peripheral for DISCO-F407G boards :-( However, MBED OS-5 is supported :-)
- Sorry, but I have never seen a tutorial on mbed-dev.
So what i want is the development board (ST Nucleo, DISCO) for faster develop and also there are core board already on the market (I don't wont to make PCB since it only a few units of production) and also support MBED 5. So far i just found NUCLEO F103RB. There are no F4 for more robust and has good ADC. CAN support is mandatory.
posted by 10 Apr 2018