2313 UBRR doesn't work correctly at high speeds

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am reluctently beginning to believe that the Baud Rate Generator on the AVR 2313 doesn't work correctly at high speeds. For example when the start bit of one character immediately follows the period of the stop bit of the previous character.
I set up a test where three characters are sent from the PC over the serial port to the AVR2313 at 38400 baud. After each character arrived into the AVR, the interrupt routine put the character into the SRAM at three subsequent memory locations. Before the arrival of the characters the memory locations were filled with sentinal values (0xAA). The stack was properly enabled and the RxCIE enabled. After each test the first character always arrived correctly, and the next two characters were wrong. Sending the same three characters from the PC with a 25millisecond pause between the characters worked perfectly.
Sending the characters at full speed between two PCs with an RS232 crossover cable worked perfectly also.
I tried the same test using 9600 baud and got the same results: 1st char OK, following chars bad.
Has anyone else noticed this situation or have suggestions?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

With a '2313 at 3.68MHz, I can run all day at 115kbps without a hiccup, using my "standard" CodeVision interrupt-driven UART routines driving an RS485 half-duplex connection.

What is your system clock speed?

I suspect you have a lengthy time with interupts disabled, and/or you are spending a lot of time in another ISR.

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

or the crystal on the AVR yields a BAUD rate clock with too much error vs. the ideal - as a multiple of the desired baud rate.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

and also - I have my own C code for the 2313's UART - works perfectly at 9600 and 19200, even with a 10MHz crystal (non-optimal).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Simonetta,
Post you code, especially your ISR. I've also run all day @115K without a hiccup.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This problem turned out to be an initialization issue. Using SBR to change bits in a temp register left a bit set from a previous instruction. This caused the UART to be in 9 bit mode. All data was being corrupted because the AVR was expecting 9 bits instead of eight.
This is the second time in ten years that I've been completely stopped by an I/O initialization issue that completely excaped me. The other was with an Intel 8051.

I sort of wish that the microcontroller manufacturers would have a place on their web sites for really strange problems that their users have had. People could upload the code and solutions that gave them great difficulty. I susppose that this site works in that fashion for AVR