go_away

Author Topic: Why can't I get more then 26.6kb/s out of Axon over USART - SOLVED  (Read 1727 times)

0 Members and 1 Guest are viewing this topic.

Offline cosminprundTopic starter

  • Robot Overlord
  • ****
  • Posts: 284
  • Helpful? 8
Why can't I get more then 26.6 kilobytes/sec out of Axon over USART?
Here's my latest code. Should keep sending 'x' for ever and ever, at maximum speed. I don't think it can be simplified more then this; I attempted writing the LoopAndSend() function in assembler but (after writing it :( ) I looked at the disassembler for the compiled code and it was the *exact* same 3 assembler instruction routine. I just don't understand! It should give 50kb/s:

Code: [Select]
#include <avr/io.h>
#define F_CPU 16000000UL  // 16 MHz
#include <util/delay.h>

// Prepare the USART for use
void PrepUSART()
{
// Make the UBRR==1 => 500,000 baud rate
UBRR1H = 0;
UBRR1L = 1;
// Reset all status bits
UCSR1A = 0;
// Enable both transmitter and receiver
UCSR1B = 0b00011000;
// Set frame format: Asynchron, 8data, 1stop bit
UCSR0C = 0b00000110;
}

// Loop & Send
void LoopAndSend()
{
while (1) {
while (bit_is_clear(UCSR1A,5)) ;
UDR1='x';
}
}

// Program Loop
int main()
{
PrepUSART();
LoopAndSend();
}
« Last Edit: February 18, 2009, 01:27:31 PM by cosminprund »

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,132
  • Helpful? 109
Re: Why can't I get more then 26.6kb/s out of Axon over USART?
« Reply #1 on: February 18, 2009, 12:38:35 PM »
Only a small point, but since you seem to be using UART 1 then you should be using 'UCSR1C' not 'UCSR0C' - doubt it will make any difference though


Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline cosminprundTopic starter

  • Robot Overlord
  • ****
  • Posts: 284
  • Helpful? 8
Re: Why can't I get more then 26.6kb/s out of Axon over USART - SOLVED
« Reply #2 on: February 18, 2009, 01:26:48 PM »
Thanks Webbot for pointing that out. It turns it did matter, but not for the data transmission rate.
Unfortunately I think I had a very bad evening last night when I wrote that because I made a tone of errors, the capital error being that I was working on one project but kept "burning" the wrong (unchanged) hex file to the Axon.

The scores are in: The data rate is 53.3 kilobytes per second.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: Why can't I get more then 26.6kb/s out of Axon over USART - SOLVED
« Reply #3 on: February 20, 2009, 09:13:44 PM »
Yea I read your post, couldn't figure out what was wrong, and hoped someone else would answer . . . shows that if I ignore a problem, it'll just go away ::)

Quote
the capital error being that I was working on one project but kept "burning" the wrong (unchanged) hex file to the Axon.
I've made that mistake a few times, so if something ever doesn't work, one of the first things I check other than battery power is if I uploaded the updated .hex.

 


Get Your Ad Here

data_list