Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32 actual baud rate is half of the configured #149

Open
thefatmoop opened this issue Sep 19, 2024 · 0 comments
Open

ESP32 actual baud rate is half of the configured #149

thefatmoop opened this issue Sep 19, 2024 · 0 comments

Comments

@thefatmoop
Copy link

thefatmoop commented Sep 19, 2024

I haven't taken a dig into why, but curious if someone can shed some light on this.

Hardware:
ESP32 using the built in CAN transceiver. Using external can PHY chip. Monitoring the TX line straight out of the esp32.

Measurements:
scope - Setting the baud rate as 500kbaud on esp32 results in a single bit width of 250khz.
salae logic analyzer - Setting the baud rate as 500kbaud on esp32, have to set salae logic to 250kbaud to decode packets.

conclusion
It looks like whatever baud is set in can.begin(baud) gets halved. Am I doing something wrong?

#include <Arduino.h>
//https://github.com/sandeepmistry/arduino-CAN/tree/master
#include <CAN.h>

#define rx 26
#define tx 27

void setup() {
  Serial.begin(115200);
  
  Serial.println("CAN Sender");
  CAN.setPins (rx, tx);

  // start the CAN bus at 250 kbps
  if (!CAN.begin(500E3)) {
    Serial.println("Starting CAN failed!");
    while (1);
  }

}

void loop() {
  // send packet: id is 11 bits, packet can contain up to 8 bytes of data
  Serial.print("Sending packet ... ");

  CAN.beginPacket(0x12);
  CAN.write('h');
  CAN.write('e');
  CAN.write('l');
  CAN.write('l');
  CAN.write('o');
  CAN.endPacket();
  Serial.println("done");
  delay(1000);

  // send extended packet: id is 29 bits, packet can contain up to 8 bytes of data
  Serial.print("Sending extended packet ... ");

  CAN.beginExtendedPacket(0xabcdef);
  CAN.write('w');
  CAN.write('o');
  CAN.write('r');
  CAN.write('l');
  CAN.write('d');
  CAN.endPacket();
  Serial.println("done");
  delay(1000);
}
@thefatmoop thefatmoop changed the title ESP32 actual baud rate is double of the configured ESP32 actual baud rate is half of the configured Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant