avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [avr-gcc-list] USART Tx Interrupts problem.


From: Rune Christensen
Subject: RE: [avr-gcc-list] USART Tx Interrupts problem.
Date: Mon, 24 Jan 2005 13:40:54 +0100

> -----Original Message-----
> From: address@hidden 
> [mailto:address@hidden On Behalf Of Yuri Vignoli
> Sent: Monday, January 24, 2005 1:26 PM
> To: address@hidden
> Subject: [avr-gcc-list] USART Tx Interrupts problem.
> 
> 
> I'm using an ATMEGA8L
> I write a interrupt routine for managing  Data Register Empty 
> interrupt, 
> but it's not called after i wrote the first char in UDR, it 
> sends only 
> this char.
> 
> This is the send function
> 
> BOOL com_send(u8_t* pBuf, u8_t nChar)
> {
>  
>   /* control if the buffer is full */
>   if .....
>   {
>     return FALSE;
>   }
>  
>   /*--- copy characters in buffer  ---*/
>   for( ..... )
>   {
>    
>     /*--- set correct index for circular buffer  ---*/
>     ......
>   }
>   /*--- disable interrupts for managing shared data which modify on 
> interrupt ---*/
>   ios_di();
>   /* buffer not empty */
>   if ....
>   {
>     /* enable interrupts */
>     UCSRB |=  (COM_UDRIE | COM_TXCIE);
>     /* write buffer char on UDR */
>     UDR = .....

This will give an interrupt and because interrupts is disabled it will not
start the interrupt handler. Wait with this until after the interrupts are
reenabled. 

>     /*--- set correct index for circular buffer  and 
> increments number 
> of char to send strored in buffer ---*/
>     .....
>   }
>   else
>   {
>     /* incrementes number of char to send strored in buffer*/
>   }
>   /* reenable interrupts */
>   ios_ei();
>  
>   return TRUE;
> }
> 
> The interrupt routine is so declared.
> 
> 
> void DataRegHandler() __attribute__ ((interrupt));
> 
> void DataRegHandler()
> {
>    /* turn a led on */
> .....
> /* get the next char on shared buffer */
> /* control if i have other chars to send, if no clear UDRIE  
> */ if .... {  ......... } }
> 
> The routine address is on the right position of inerrupt vector and 
> interrputs on TXCIE and UDRIE are set  in send function.
> 
> Regards,
> 
> Yuri Vignoli.

Rune
---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0503-2, 21-01-2005
Tested on: 24-01-2005 13:40:54
avast! - copyright (c) 1988-2004 ALWIL Software.
http://www.avast.com






reply via email to

[Prev in Thread] Current Thread [Next in Thread]