[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: Christoph Plattner
Subject: Re: [avr-gcc-list] using UART to send from within SIGNAL(SIG_UART_RECV) function
Date: Tue, 02 Apr 2002 12:32:45 +0200

No, in general, the idea is not bad !
IMO it is necessary to give a transmitt character to the UART to send,
for example to implement XON/XOFF !

But it should be done in the right way !

First of all, the TX interruot service routine should place characters
into the TX buffer of the UART, and the RX service routine should give
the character to transmitt buffer behind the IRQ service routine.

Bad design is, to do a busy waiting.

I wrote an UNIX-like OS for the AVR (currently using Mega-103, before I
used the 8515 and 4414) and I implemented a Linux-Device-Driver-like
interface and I wrote the UART character device driver using in/out
ring buffers, interrupt service routines, bottom half routines for the
wake-up (bottom half is a "software interrupt", hwo can handle i/o work,
which is not necessary to be done while hardware interrupt) and
a Linux-like sleep()/wakeup() mechanism.

At the moment I work on a solution for the library code. I really think
about the idea porting the complete newlib (!). Currently only the
calls can be used to do "fork()", "wait()". open/read/write/ioctl,
Perhaps I will put my system into an open-source project!

Mr. Wunsch has right. To discuss the stuff, we need the code here...

Christoph Plattner

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
> character.
> 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
> like
> volatile struct {
>         uint8_t rx_int: 1;
>         ...
> } intflags;
> volatile uint8_t rxbuff;
> {
>         uint8_t c;
>         c = inp(UDR);
>         if (bit_is_clear(UCSRA, FE))
>         {
>                 rxbuff = c;
>                 intflags.rx_int = 1;
>         }
> }
> ....
> main()
> {
>         for (;;) {
>                 ...
>                 if (intflags.rx_int) {
>                         intflags.rx_int = 0;
>                         <insert your stuff here>
>                 }
>         }
> }
> --
> J"org Wunsch                                           Unix support engineer
> address@hidden        http://www.interface-systems.de/~j/
> avr-gcc-list at http://avr1.org

private:        address@hidden
company:        address@hidden

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

reply via email to

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