Giter VIP home page Giter VIP logo

Comments (28)

Toernblom avatar Toernblom commented on June 15, 2024

image

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.

nopnop2002 avatar nopnop2002 commented on June 15, 2024

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.

Toernblom avatar Toernblom commented on June 15, 2024

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.

image

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.

nopnop2002 avatar nopnop2002 commented on June 15, 2024

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.

Toernblom avatar Toernblom commented on June 15, 2024

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.

nopnop2002 avatar nopnop2002 commented on June 15, 2024

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.

Toernblom avatar Toernblom commented on June 15, 2024

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.

nopnop2002 avatar nopnop2002 commented on June 15, 2024

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.

Toernblom avatar Toernblom commented on June 15, 2024

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.

nopnop2002 avatar nopnop2002 commented on June 15, 2024

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.

Toernblom avatar Toernblom commented on June 15, 2024

Can't use bluepill or blackpill in platformio.ini file to make serial work. If i use genericSTM32F103R8 with HardwareSerial its fine.
image
its because
image

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.

Toernblom avatar Toernblom commented on June 15, 2024

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.

nopnop2002 avatar nopnop2002 commented on June 15, 2024

Keep STAB length as short as possible.

from arduino-stm32-can.

Toernblom avatar Toernblom commented on June 15, 2024

image

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.

nopnop2002 avatar nopnop2002 commented on June 15, 2024

If you have a BluePill or BlackPill, you can identify the problem.

Try BluePill or BlackPill.

from arduino-stm32-can.

Toernblom avatar Toernblom commented on June 15, 2024

Sadly I don't. I can purchase one however if you think that would help ?

from arduino-stm32-can.

nopnop2002 avatar nopnop2002 commented on June 15, 2024

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.

Toernblom avatar Toernblom commented on June 15, 2024

The connection:
image
image

image

Your code says that the initialization was ok. I don't think theres anything wrong with the wiring here..

from arduino-stm32-can.

Toernblom avatar Toernblom commented on June 15, 2024

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.

nopnop2002 avatar nopnop2002 commented on June 15, 2024

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.

80896902-3d9e0680-8d2e-11ea-9add-0a102f43c3a7

from arduino-stm32-can.

Toernblom avatar Toernblom commented on June 15, 2024

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.

amitesh-singh avatar amitesh-singh commented on June 15, 2024

@Toernblom have you found the solution?

from arduino-stm32-can.

nopnop2002 avatar nopnop2002 commented on June 15, 2024

@Toernblom
@amitesh-singh

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.

Toernblom avatar Toernblom commented on June 15, 2024

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.

amitesh-singh avatar amitesh-singh commented on June 15, 2024

@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.

amitesh-singh avatar amitesh-singh commented on June 15, 2024

image
image

cc @Toernblom @nopnop2002

from arduino-stm32-can.

amitesh-singh avatar amitesh-singh commented on June 15, 2024

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.

nopnop2002 avatar nopnop2002 commented on June 15, 2024

@amitesh-singh

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.

IMG_5156
S1d81667d39154041a45fbe1b16230516k

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.

Test-Circuit

This is the receiver logging
stm32f103-can

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.