UART speed

Post here first, or if you can't find a relevant section!
Post Reply
jenspogo
Posts: 30
Joined: Mon Feb 24, 2020 10:42 am

UART speed

Post by jenspogo »

Hey guys,

I would like to speed up my UART communication.
actually it looks like this:
K800_UART_Timing_02.JPG
K800_UART_Timing_02.JPG (65.78 KiB) Viewed 2978 times
I would like to increase the time between the bits where nothing happens.
I'm using a Bluepill Board with the offical core.
My Code looks like this:

Code: Select all

#define SAMPLERATE 2000000

HardwareSerial  mySerial(PA3, PA2); // RX, TX
int i = 64;

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
 
  // set the data rate for the HardwareSerial port
  mySerial.begin(SAMPLERATE);
  
}

void loop() { // run over and over

  mySerial.write("<");
  mySerial.write("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
//  while (i <(94))
//  {
//  mySerial.write(i);
//  i++;
//  }
  mySerial.write(">");
  delay(10);                       // wait for a second
  digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));

i = 64;  

}
Im using "<" and ">" as start and stop on the receiver.

Is there any possibility?

Greetings,
Jens
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: UART speed

Post by mrburnette »

Speed up? Like compressing but not really increasing the BAUD? Ummmm ... Serial is governed by Standards:
https://www.sealevel.com/support/overvi ... standards/

Re: https://www.electronicdesign.com/techno ... -baud-rate

Staying in the Arduino framework, we could just choose to not utilize the default serial and use SPI instead:
https://www.sciencedirect.com/topics/co ... /baud-rate

Of course, the above would require SPI ---> Serial conversion on the target end!

You can also just change the protocol:
https://forum.arduino.cc/index.php?topi ... msg2527550

If you really want to go structured, you can send/receive C structs. Reference Struct_send and Struct_receive libs:
https://github.com/LowPowerLab/RFM69/tr ... r/Examples
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: UART speed

Post by stevestrong »

remove delay(10)...
Post Reply

Return to “General discussion”