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

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

RE: [avr-gcc-list] Problems with ATMEGA8 USART


From: Nigel Winterbottom
Subject: RE: [avr-gcc-list] Problems with ATMEGA8 USART
Date: Wed, 17 Aug 2005 09:36:28 +0100

David Kelly wrote:

Thats not quite what I meant. I do enable the IRQ for each character.  
The issue was in finding which UART needed to be enabled without  
enabling one which would then serve an empty event. Here is the exact  
code I wrote back in December. Today I'd probably bracket the  
insertion and masking with cli()/sei().

int
uputc( int c, Uart *fp )

----------------------------

Aaah!
OK!

My Transmit function is:

//TxChar Add a Character to USART transmit buffer. Return true if error.
//---------------------------------------------------------------
bool TxChar (unsigned char uart_no, char data)
{
struct uartdesc_s *pUD;         //Pointer to Uart Descriptor 0 or 1
struct uartflag_s copyUartF;    //Temporary copy of UartF
unsigned char *pBuff;           //Pointer to TxBuff0 or TxBuff1
unsigned char txlen;
bool retval;

if (uart_no==0)
     { pUD=&UD0; pBuff=TxBuff0; txlen=TXLEN0; }
else { pUD=&UD1; pBuff=TxBuff1; txlen=TXLEN1; }

cli();                                  //disable global interrupts
copyUartF=pUD->UartF;                   //Temporary copy of UartF

....... etc. etc.

//Restart COMMS
if (uart_no==0)
        UCSRB |= 1<<UDRIE;                              //Enable Tx
buffer empty IRQ to Restart COMMS
else{

....... etc. etc.

pUD->UartF=copyUartF;
sei();                                                  //Re-enable
global interrupts

return (retval);
}



I have direct knowledge of which USART I am dealing with, therefore I
couldn't see your problem.

Regards

Nigel




reply via email to

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