2024-12-10 10:10 PM
Setup- I am using Platform I/o to upload code to STM32 , Teensy. I am Sending Data from one STM to another STM via CAN and the message that I received on STM I am communicating it through UART to Teensy to Serial print it. I couldn't Serial print using STM directly so I am using Teensy.
Issue- My UART Communication works fine when I remove all the CAN statements from the code but when I write just can.begin(500000) then My Serial monitor prints just S when I said it to print
2024-12-10 10:45 PM
> ... but when I write just can.begin(500000) ...
Sounds like you talk about Arduino here.
> ... so I am using Teensy.
Nor did you mention the hardware you are using.
All this information would be crucial.
> My UART Communication works fine when I remove all the CAN statements from the code but when I write just can.begin(500000) then My Serial monitor prints just S when I said it to print
2024-12-10 11:36 PM
I am using STM32F103C6T6 for this communication and Teensy 4.o. Sorry for writing it wrong , I actually meant can.setbaudrate(500000) and yes , I am using arduino Framework in Platform I/o. Hardware stuff - I am having two Transceivers SN65HVD230 and I checked the working of them by making a CAN communication between two teensy's using those transceivers. I am using Jumpers to make all the Connections which are - Teensy 0,1,G pins connected to receiving STM A9,A10,Ground respectively and A11 , A12 of receiving STM to CAN RX and TX of one transceiver. 3.3V to transceiver and 120 ohm resistance between CANH and CANL in split. CANH of both Transceivers are shorted respectively CANL's too. Transmitting STM pins A11 , A12 are also connected to Transceivers RX and TX respectively. This all I am doing on a Breadboard and the CAN transceivers are soldered on PCB. I even uploaded the codes that I have written , Could you please verify them?
2024-12-11 12:27 AM
> I am using Jumpers to make all the Connections which are - Teensy 0,1,G pins connected to receiving STM A9,A10,Ground respectively and A11 , A12 of receiving STM to CAN RX and TX of one transceiver.
Does that mean that PA9 + PA10 are the UART pins, and PA11 + PA12 the CAN pins ?
That would be ok.
> Could you please verify them?
I did have a look at it, but lacking the hardware, environment and experience with Arduino, I cannot confirm anything. Superficially it seems fine.
> I checked difference between CANH and CANL on Oscilloscope and I am always getting it to be 0. So CAN communication isn't happening.
The CAN bus is very different from UART, not sure if you are aware.
You need at least one other CAN node to get actual CAN transfers.
And you need at least a termination resistor (between CANH and CANL) to see something on the scope. Still, the CAN peripheral would go into "error passive" and bus-off mode eventually, when it doesn't get an acknowledge for transmission attempts.
You can check the CAN-TX pin of the STM32 with a scope, a signal should be visible there when the initiialisation was ok and you try to send.