Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

USART on mega48

USART on mega48

2006-10-04 by Aaron

I struggled yesterday getting the USART on a Mega48 to work.

Since I got a good nights sleep, I'm going to take another look at the 
datasheet and my code before I post my initialization.  But in the 
meantime, I never see UDR0 being filled with data, both in the simulator 
or via debugwire.  Assuming the USART is properly configured, does 
anybody know if I should be able to see this happen?

As an aside, I tried the new Dragon for the first time yesterday.  
Pretty painless.  My only complaint thus far is the packaging - I wish 
it at least had some rubber feet on the bottom.  But for $49 it is a 
great product!

Aaron

Re: [AVR-Chat] USART on mega48

2006-10-04 by moemen issa

I've used Atmel's AVR studio in simulation of the USART and it doesn't show any data in the UDR reg. , but it worked pretty good although ,I think its an internal thing that you can'nt see the UDR filled with data...

Aaron <aaron.groups@gmail.com> wrote:          I struggled yesterday getting the USART on a Mega48 to work.

Since I got a good nights sleep, I'm going to take another look at the 
datasheet and my code before I post my initialization. But in the 
meantime, I never see UDR0 being filled with data, both in the simulator 
or via debugwire. Assuming the USART is properly configured, does 
anybody know if I should be able to see this happen?

As an aside, I tried the new Dragon for the first time yesterday. 
Pretty painless. My only complaint thus far is the packaging - I wish 
it at least had some rubber feet on the bottom. But for $49 it is a 
great product!

Aaron



         



 		
---------------------------------
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2ยข/min or less.

[Non-text portions of this message have been removed]

Re: [AVR-Chat] USART on mega48

2006-10-04 by Aaron

moemen issa wrote:

>I've used Atmel's AVR studio in simulation of the USART and it doesn't show any data in the UDR reg. , but it worked pretty good although ,I think its an internal thing that you can'nt see the UDR filled with data...
>  
>
Thanks.  I wondered if that might be what happens in the simulator, and 
perhaps the debugwire acts this way, too.

Another look through the code didn't turn up anything, so when I get 
home tonight, I'll break out the scope and monitor the pin for 
activity.  Maybe there is something wrong with my level conversion 
circuitry.

Aaron

Re: [AVR-Chat] USART on mega48

2006-10-04 by John Samperi

At 10:05 PM 4/10/2006, you wrote:
>I struggled yesterday getting the USART on a Mega48 to work.

Remember that the USART in the Mega 48/88/168 is **NOT** in the
I/O space but in RAM space therefore the code example in the data
sheet will NOT WORK. You will need to use STS/LDS to access the
USART's registers. Holler if you want more info :-)


Regards

John Samperi

********************************************************
Ampertronics Pty. Ltd.
11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
Tel. (02) 9674-6495       Fax (02) 9674-8745
Email: john@ampertronics.com.au
Website  http://www.ampertronics.com.au
*Electronic Design * Custom Products * Contract Assembly
********************************************************

Re: [AVR-Chat] USART on mega48

2006-10-05 by bibin john

see these links
   
  http://booksbybibin.14.forumer.com/viewtopic.php?t=119
  http://booksbybibin.14.forumer.com/viewtopic.php?t=108
  http://booksbybibin.14.forumer.com/viewtopic.php?t=122
  http://booksbybibin.14.forumer.com/viewtopic.php?t=118
  http://booksbybibin.14.forumer.com/viewtopic.php?t=120

   
  Bibin John
  www.bibinjohn.tk
John Samperi <samperi@ampertronics.com.au> wrote:
          At 10:05 PM 4/10/2006, you wrote:
>I struggled yesterday getting the USART on a Mega48 to work.

Remember that the USART in the Mega 48/88/168 is **NOT** in the
I/O space but in RAM space therefore the code example in the data
sheet will NOT WORK. You will need to use STS/LDS to access the
USART's registers. Holler if you want more info :-)

Regards

John Samperi

********************************************************
Ampertronics Pty. Ltd.
11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
Tel. (02) 9674-6495 Fax (02) 9674-8745
Email: john@ampertronics.com.au
Website http://www.ampertronics.com.au
*Electronic Design * Custom Products * Contract Assembly
********************************************************



         

 				
---------------------------------
 Find out what India is talking about on  - Yahoo! Answers India 
 Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8. Get it NOW

[Non-text portions of this message have been removed]

Re: [AVR-Chat] USART on mega48

2006-10-06 by Aaron

bibin john wrote:

>see these links
>   
>  http://booksbybibin.14.forumer.com/viewtopic.php?t=119
>  http://booksbybibin.14.forumer.com/viewtopic.php?t=108
>  http://booksbybibin.14.forumer.com/viewtopic.php?t=122
>  http://booksbybibin.14.forumer.com/viewtopic.php?t=118
>  http://booksbybibin.14.forumer.com/viewtopic.php?t=120
>
>   
>  Bibin John
>  www.bibinjohn.tk
>
>  
>
Wow, very comprehensive write-up... thanks for the links.



John Samperi wrote:

>
>Remember that the USART in the Mega 48/88/168 is **NOT** in the
>I/O space but in RAM space therefore the code example in the data
>sheet will NOT WORK. You will need to use STS/LDS to access the
>USART's registers. Holler if you want more info :-)
>  
>
Well, the compiler was taking care of that for me.

----------

After looking at the listing of the generated code, I am happy to report 
that I did find the problem.
However, I am unhappy to report the amount of time it took, so I won't.  :)

Anyway, I had written:

    void USART_transmit (unsigned char data)
    {
        while (!(UCSR0A & (1<<UDRE0)))    // wait for empty transmit buffer
        UDR0 = data;                    // send the data
    }


When I should have written:

    void USART_transmit (unsigned char data)
    {
        while (!(UCSR0A & (1<<UDRE0)))    // wait for empty transmit buffer
            ;                           <------------------ SEE WHAT I 
FORGOT??????
        UDR0 = data;                    // send the data
    }


duhhh!!!

Aaron

Re: [AVR-Chat] USART on mega48

2006-10-06 by John Samperi

At 12:23 PM 6/10/2006, you wrote:
>Well, the compiler was taking care of that for me.

I can see that!! :-D would not have had all these problems
had you written it in assembler ;-)

Regards

John Samperi

********************************************************
Ampertronics Pty. Ltd.
11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
Tel. (02) 9674-6495       Fax (02) 9674-8745
Email: john@ampertronics.com.au
Website  http://www.ampertronics.com.au
*Electronic Design * Custom Products * Contract Assembly
********************************************************

Re: [AVR-Chat] USART on mega48

2006-10-06 by David VanHorn

>
>
> I can see that!! :-D would not have had all these problems
> had you written it in assembler ;-)



VBG!


-- 
> Feel the power of the dark side!  Atmel AVR


[Non-text portions of this message have been removed]

Re: [AVR-Chat] USART on mega48

2006-10-06 by Aaron

David VanHorn wrote:

>>I can see that!! :-D would not have had all these problems
>>had you written it in assembler ;-)
>>    
>>
>
>
>
>VBG!
>  
>

This is starting to feel like the ASM vs. C war.  :)

In the compiler's defense, it did exactly what I told it.

In my defense, it's my first real project with C since my classes 8 
years ago... my other AVR endeavors have all been with ASM.  :)

Aaron
Show quoted textHide quoted text
>
>  
>

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.