Jump to content
Tuts 4 You

AVR Assembly USART problem


Recommended Posts

Hey all,

Something else than those C++ and x86 asm programming stuff topics. :)

Let's hope someone knows soemthing.

I've been attempting to code an interrupt driven usart connection between an AVR chip board and the PC. (the PC is sending the data)

However it seems that when an byte is recieved it keeps giving interrupts even when the buffer is read. (which should stop that according to the datasheet)

Interrupt code which is properly triggered when recieving a byte but just keeps interrruptingand spamming my terminal:

;store incoming bytes
in r24,UDR
out UDR, r24

Am I missing something here.

Afaik I am initing the serial connection properly.



Edited by quosego
Link to comment

You could try using "cli" instruction to disable interrupts before reading the buffer.

As far as i know, you must disable the Interrupts, before you read...

at the end of the interrupt, you can reenable it.

Link to comment

Thnx for the replies, tried them both but no effect.

I think some flag must be reset but I've reset about every flag there is..

Why can't they run everything on x86... :) That at least works. :D

Link to comment

This is a silly question, but there is not a 'control value' passed by which tells the AVR to stop triggering the interrupt? As, is there 0x00 - 0xFF available as valid 'data' byte values or is there a reserved byte like the null which terminates a C string?



Link to comment

Do you know that:

The Status Register is not automatically stored when entering an interrupt routine and restored

when returning from an interrupt. This must be handled by software.

The SREG – AVR Status Register contains "Bit 7 – I: Global Interrupt Enable" .

Edited by GaBoR
Link to comment

Hey thanks all..

But I've found it, seems the cable was crap... And generated Stuff that wasn't there. Stupid cable programmed the thing fine but when doing simple connections it went bonkers.

New cable and now all is fine.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...