Jump to content
Tuts 4 You

AVR Assembly USART problem


quosego

Recommended Posts

Posted (edited)

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:


Serial_Recieve:
;store incoming bytes
in r24,UDR
out UDR, r24
reti

Am I missing something here.

Afaik I am initing the serial connection properly.

regards,

q.

Edited by quosego
Posted

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

Posted

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.

Posted

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

Posted

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?

HR,

Ghandi

Posted (edited)

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
Posted

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.

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...