[Top][All Lists]

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

Re: [avr-gcc-list] using UART to send from within SIGNAL(SIG_UART_RECV)

From: Karsten Becker
Subject: Re: [avr-gcc-list] using UART to send from within SIGNAL(SIG_UART_RECV) function
Date: Tue, 02 Apr 2002 15:24:53 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.9) Gecko/20020311

Joerg Wunsch wrote:

Karsten Becker <address@hidden> wrote:

When I try to send from within the SIGNAL(SIG_UART_RECV) function, the sending stops after one character.
Is there any way to make it possible to send from within this function?

Guess you gotta post your code in order to get help.

Anyway, it's IMHO a bad idea to abuse an interrupt service routine to
do this kind of task, in particular since you're most likely using a
busy-wait loop in order to see when to start sending the next

It's usually better to minimize the code inside the ISRs, and just set
a bit that can be evaluated inside the program's main loop.  Something

That is exactly what i wanted to replace by the Interrupt driven method because of the "high" latency. Maybe one of the problems is that the code inside the SIGNAL(SIG_UART_RECV) has 178lines in original. But there are many if that lead in something like 4-6 cycles to the bit longer PRINT routine.
I'm using 115200Baud.
What I do is:

#define PRINT(string) (UART_PrintfProgStr(PSTR(string)))

void UART_PrintfProgStr(u08* pBuf)
   /* wait for UART to become available */
   UART_Ready = 0;
   /* Indicate to ISR the string to be sent */
   pUART_Buffer = pBuf;
   /* Send first character */
   outp( PRG_RDB(pUART_Buffer), UDR );

/* UART Transmit Complete Interrupt Function */
   /* Test if a string is being sent */
   if (pUART_Buffer!=0)
       /* Go to next character in string */
       /* Test if the end of string has been reached */
       if (PRG_RDB(pUART_Buffer)==0)
           /* String has been sent */
           pUART_Buffer = 0;
           /* Indicate that the UART is now ready to send */
           UART_Ready   = 1;
       /* Send next character in string */
       outp( PRG_RDB(pUART_Buffer), UDR );
   /* Indicate that the UART is now ready to send */
   UART_Ready = 1;

   /* Store received character */
   UART_RxChar = inp(UDR);
   if (UART_RxChar ==5) {
       PRINT("Bad choice, try again");

Thanks, Karsten

avr-gcc-list at http://avr1.org

reply via email to

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