View Single Post
Old 06-05-2009, 12:03 PM   #1562 (permalink)
charlie_fd
EcoModding Lurker
 
Join Date: May 2009
Location: Bucharest,RO and Copenhagen,DK
Posts: 42
Thanks: 0
Thanked 1 Time in 1 Post
Quote:
Originally Posted by MazdaMatt View Post
quick googling turned up nothing... are the atmel users just not interested in interrupt driven communication? Every uart code snippet I saw had a while(blah blah){sit here with your thumb up your...}
....
Code:
FUNCTION Main
  Enable Global Interrupts

  LOOP FOREVER
    {Do Stuff}
    Transmit_Data(Data)
    Sleep
  END LOOP
END FUNCTION

FUNCTION Transmit_Data(Data)
  Store Data into RingBuffer
  Enable TX Buffer Empty Interrupt (instead of Dean's TX Complete Interrupt)
END FUNCTION

ISR TX_BUFFER_EMPTY_ISR
  IF RingBuffer NOT EMPTY
    UDR = RingBuffer.Next
  ELSE
    Disable TX Buffer Empty Interrupt
  END IF
END ISR
More about that, including a link to a ringbuffer implementation fond in the same place as the (pseudo)code above: View topic - [TUT] [SOFT] Using the USART - Interrupt driven serial comms :: AVR Freaks
  Reply With Quote