Comments (28)
Errors while running. I've used the same cables with another board using CAN so shouldn't be an issue. Terminations is ok aswell because other devices can talk to each other.
from arduino-stm32-can.
Regarding send fail, past issues (closed issues) are helpful.
Mostly due to terminating resistors or cable quality.
Many people have encountered this problem and solved it by changing the terminator or STAB wire cable.
When STM32 is added to CAN-BUS in operation, the impedance may change due to STAB.
When adding nodes, pay attention to the length of the STAB cable.
from arduino-stm32-can.
I currently have 3 nodes, 2 of them are talking and all has twisted shielded pairs which are 5-10cm in length and the shield is grounded. It's the only device on the network that can't talk. The resistance between CAN_L & CAN_H is ~60 Ohm so that isn't an issue either. I've also checked previous closed issues and tried those aswell. All baudrates is 100kbps to minimize noise.
These are the prints from your code. I noticed that the peripheral_clock_rate was at 32mhz while STM32F103R8 that i'm using is at 72mhz so i tried changing that aswell to the correct clock with no success
from arduino-stm32-can.
peripheral_clock_rate is not cpu frreuency.
cpu frreuency = peripheral_clock_rate x 2
Arduino core support for STM32 based boards uses different clock frequencies depending on the Board Part Number.
BlackPill & BluePill use 72Mhz.
Generic board use 64Mhz.
If the receive works correctly, it's not a CPU frequency issue.
The resistance between CAN_L & CAN_H is ~60 Ohm
I think It's too small.
from arduino-stm32-can.
Hmm okey, then peripheral_clock_rate should be 36mhz then? Since STM32F103R8T6 is 72Mhz not 64.
The receive did work yesterday, not anymore for some reason.. I saw your previous comment on another issue with 150 Ohm termination, I'll try that!
from arduino-stm32-can.
Since STM32F103R8T6 is 72Mhz not 64.
peripheral_clock_rate is not cpu frreuency.
cpu frreuency = peripheral_clock_rate x 2
Arduino core support for STM32 based boards uses different clock frequencies depending on the Board Part Number.
BlackPill & BluePill use 72Mhz.
Generic board use 64Mhz.
You can check your board CPU freqiency using the F_CPU macro
Serial.println(F_CPU);
from arduino-stm32-can.
Hmm, that result gave 64 Mhz. In my Platformio.ini file , the board is genericSTM32F103R8.
Should i switch out the board part number?
from arduino-stm32-can.
Should i switch out the board part number?
If you use bluepill or blackpill in Platformio.ini, it will be 72Mhz.
It has nothing to do with this issue.
But everyone gets confused.
from arduino-stm32-can.
Haha i understand why. We use a custom made PCB with STM32F103R8T6 and It's the first time with the STM32 chip family. So I thought i'd should use the genericSTM32F103R8 in the .ini file , not blackpill or bluepill ..
But if i use the genericSTM32F103R8 F_CPU shows 64Mhz
from arduino-stm32-can.
I think you can build custom boards using BluePill and BlackPill variants.
However, the GPIO of the Serial object changes for the Generic board, BluePill, and BlackPill.
The output destination of Serial.print differs depending on the Board Part Number.
BluePill:PA9
BlackPill:PA9
Generic F103:PA2
everyone gets confused.
from arduino-stm32-can.
Can't use bluepill or blackpill in platformio.ini file to make serial work. If i use genericSTM32F103R8 with HardwareSerial its fine.
its because
However, if i do use genericSTM32F103R8 F_CPU is wrong and if i use either bluepill or blackpill in .ini the f_CPU is correct..
I do understand that everyone gets confused..
from arduino-stm32-can.
I have replaced the termination resistors with 150 Ohm so that i have two terminations at the ends with a bus resistance at 75 Ohm now. No success in sending any data.
from arduino-stm32-can.
Keep STAB length as short as possible.
from arduino-stm32-can.
This is the setup, the connection between the raspberry pi on the right and the CAN analyze tool on the bottom has no shielded nor twisted pairs. I'm not sure the cables are the issues..
from arduino-stm32-can.
If you have a BluePill or BlackPill, you can identify the problem.
Try BluePill or BlackPill.
from arduino-stm32-can.
Sadly I don't. I can purchase one however if you think that would help ?
from arduino-stm32-can.
There may be a problem with your custom made PCB.
If it works fine with BluePill/BlackPill, then there may be a problem with your custom made PCB.
BluePill/BlackPill works absolutely.
from arduino-stm32-can.
Your code says that the initialization was ok. I don't think theres anything wrong with the wiring here..
from arduino-stm32-can.
Alright, found out the reason why reading stop worked. It was cause i was monitoring on the UART. If i only powered it on and ran with debug i could read messages. Not send however. Its quite weird actually.
If dont use Hardware Serial at PA10 & PA9
Then the code gets stuck here
CANInit(CAN_250KBPS, 2);
Stepping over CANInit function with debugging results in the debug can't step over and gets stuck inside this function
ComputeCANTimings(HAL_RCC_GetPCLK1Freq(), target_bitrate, &timings);
Digging further it goes to stm32f1xx_hal_rcc.c
and gets stuck here
uint32_t HAL_RCC_GetPCLK1Freq(void)
{
/* Get HCLK source and Compute PCLK1 frequency ---------------------------*/
return (HAL_RCC_GetHCLKFreq() >> APBPrescTable[(RCC->CFGR & RCC_CFGR_PPRE1) >> RCC_CFGR_PPRE1_Pos]);
}
And if i do use Hardware Serial at PA10 & PA9
the code doesn't hang on that line and continues running and i can successfully read messages on the CAN bus. But CANSend hangs here:
while (CAN1->sTxMailBox[0].TIR & 0x1UL && count++ < 1000000);
from arduino-stm32-can.
It was cause i was monitoring on the UART.
This is the UART output.
Something is wrong.
Testing on a custom PCB is even more confusing.
Testing on a custom PCB doesn't reveal anything.
from arduino-stm32-can.
Alright, If i put a delay between Serial.begin and CANInit the code doesn't hang anymore. Still getting Send Fail no matter what i do, I've got another CAN Node with the same tranciever, TJA1050 , exact same cables and length on the network that is working well, custom made PCB aswell..
from arduino-stm32-can.
@Toernblom have you found the solution?
from arduino-stm32-can.
It's not a clone chip, right?
Doesn't work properly with clone chips.
https://hackaday.com/2020/10/22/stm32-clones-the-good-the-bad-and-the-ugly/
from arduino-stm32-can.
Hi, it was a fault within the PCB. I think it was some issue with different logic levels between the IC's of the MCU and CAN controller & transciever.
from arduino-stm32-can.
@Toernblom @nopnop2002 Thanks for the reply.
Is it due to powering tja1050 by 5v and stm32f103 is powered from 3.3v?
from arduino-stm32-can.
from arduino-stm32-can.
the PB8 and PB9 pins are 5v tolerant and tja1050 should work with 3.3v devices, that's what they claim in their datasheet as tja1050 RXD is a totem pole and voltage varies from 0.7Vcc to 0.45v
from arduino-stm32-can.
the PB8 and PB9 pins are 5v tolerant
Yes. You are right.
I powered the STM32F103 from USB and tried it with the 5V transceiver TJA1051.
The terminating resistor worked correctly with both 100 ohm and 150 ohm.
My TJA1051 has components marked 4017V installed.
I don't know what this is.
My test circuit.
The Nano on the left is a receiver with a terminating resistor.
The Nano on the right is a transmitter without a terminating resistor.
TJA1051 has a terminating resistor.
When CAN-BUS has a mix of 3.3V and 5V transceivers, +1V Ground Shift with Split Termination is effective
https://www.ti.com/lit/an/slla337/slla337.pdf
from arduino-stm32-can.
Related Issues (20)
- the lib didn't work well HOT 4
- Send Fail HOT 16
- Canard HOT 1
- Raspberry Pi wiring example issue HOT 1
- CAN messages dropped, sometime receiving message up to six times HOT 9
- STM32F103C8T6 hangs on CANInit(CAN_1000KBPS, 2) HOT 3
- STM32F103 gets stuck inside while (!(CAN1->MSR & 0x1UL)); HOT 26
- Send Fail on STM32F407VE HOT 15
- how is Serial and CAN being used simultaneously in STM32F103? HOT 3
- STM32F413ZH NUCLEO-F413ZH HOT 13
- CAN on STM32G4 series HOT 1
- Discuss: other ways to clear mailbox? HOT 1
- Mistake in Line 277 HOT 5
- STM32F042F6P6TR HOT 1
- feature request: support multiple transmit mailboxes HOT 12
- BARTH STG-850 Support HOT 5
- Unable to communicate STM32f103 vs ESP32 via CAN BUS HOT 2
- Sending data issue HOT 9
- dlc bigger than 8 HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduino-stm32-can.