Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

eCos update

eCos update

2004-02-27 by Jean-Rene David

I now have eCos running on my IAR KickStart card
with a LPC2106. RedBoot also runs, though I wasn't
yet able to download a program in RAM and execute
it from RedBoot.

I had to correct some stuff in the bugzilla port
to get rid of compiler errors and warnings and get
the thing working.

A few of the things that still need to get done:

- Flash driver for the onboard Flash
- Clarify the PLL configuration code. Right now
  there's nothing "real" about the real-time
  clock...
- get eCos and an application compiled and working
  in thumb instruction set.
- etc.

How are the other people running eCos on the
LPC2000 doing? Maybe we should start contributing
to the bugzilla port at some point, instead of
doing our separate thing.

RE: [lpc2000] eCos update

2004-03-01 by Benjamin PRADAYROL

What is the footprint's size of ecos on LCP ?  

Thx

Ben

-----Message d'origine-----
De : Jean-Rene David [mailto:jrdavid@...] 
Envoyé : vendredi 27 février 2004 18:53
À : lpc2000@yahoogroups.com
Objet : [lpc2000] eCos update

I now have eCos running on my IAR KickStart card with a LPC2106. RedBoot
also runs, though I wasn't yet able to download a program in RAM and execute
it from RedBoot.

I had to correct some stuff in the bugzilla port to get rid of compiler
errors and warnings and get the thing working.

A few of the things that still need to get done:

- Flash driver for the onboard Flash
- Clarify the PLL configuration code. Right now
  there's nothing "real" about the real-time
  clock...
- get eCos and an application compiled and working
  in thumb instruction set.
- etc.

How are the other people running eCos on the LPC2000 doing? Maybe we should
start contributing to the bugzilla port at some point, instead of doing our
separate thing.


 
Yahoo! Groups Links

Circular buffers

2004-03-04 by Curt Powell

Can someone point me to some circular buffer routines?
 
TIA,
 
Curt

Re: Circular buffers

2004-03-04 by embeddedjanitor

--- In lpc2000@yahoogroups.com, "Curt Powell" <curt.powell@s...> 
wrote:
> Can someone point me to some circular buffer routines?
There are various ways to implement circular buffers. The easiest 
way, and most robust way, IMHO is to use a counter to track how many 
items are in the list rather than comparing head and tail.

example
typedef struct{
  U8 fifo[uart_FIFO_SIZE];
  U32 head;
  U32 tail;
  U32 holding;
} uart_Buffer;
      // put a byte into the list
      if(s->rx.holding >= uart_FIFO_SIZE)
      {
        //Full, so got to throw away the oldest byte
        s->rx.holding = uart_FIFO_SIZE - 1;
        s->rx.tail++;
        if(s->rx.tail >= uart_FIFO_SIZE)
        {
          s->rx.tail = 0;
        }
      }
      s->rx.fifo[s->rx.head] = b;
      s->rx.head++;
      if(s->rx.head >= uart_FIFO_SIZE)
      {
        s->rx.head = 0;
      }
      s->rx.holding++;


  // pull a byte out of the list
  if(s->rx.holding > 0)
  {
    *pData = s->rx.fifo[s->rx.tail];
    s->rx.tail++;
    if(s->rx.tail  >= uart_FIFO_SIZE)
    {
      s->rx.tail = 0;
    }
    s->rx.holding--;
    retval = 1;
  }

  // initialise
  s->rx.tail = s->rx.head = s->rx.holding = 0;

RE: [lpc2000] Re: Circular buffers

2004-03-04 by Curt Powell

Charles,

Do you find this version to be "thread safe" when a UART ISR is filling
it and the main program is processing (i.e. emptying) it?

Curt
Show quoted textHide quoted text
-----Original Message-----
From: embeddedjanitor [mailto:charles.manning@...] 
Sent: Thursday, March 04, 2004 11:49 AM
To: lpc2000@yahoogroups.com
Subject: [lpc2000] Re: Circular buffers


--- In lpc2000@yahoogroups.com, "Curt Powell" <curt.powell@s...> 
wrote:
> Can someone point me to some circular buffer routines?
There are various ways to implement circular buffers. The easiest 
way, and most robust way, IMHO is to use a counter to track how many 
items are in the list rather than comparing head and tail.

example
typedef struct{
  U8 fifo[uart_FIFO_SIZE];
  U32 head;
  U32 tail;
  U32 holding;
} uart_Buffer;
      // put a byte into the list
      if(s->rx.holding >= uart_FIFO_SIZE)
      {
        //Full, so got to throw away the oldest byte
        s->rx.holding = uart_FIFO_SIZE - 1;
        s->rx.tail++;
        if(s->rx.tail >= uart_FIFO_SIZE)
        {
          s->rx.tail = 0;
        }
      }
      s->rx.fifo[s->rx.head] = b;
      s->rx.head++;
      if(s->rx.head >= uart_FIFO_SIZE)
      {
        s->rx.head = 0;
      }
      s->rx.holding++;


  // pull a byte out of the list
  if(s->rx.holding > 0)
  {
    *pData = s->rx.fifo[s->rx.tail];
    s->rx.tail++;
    if(s->rx.tail  >= uart_FIFO_SIZE)
    {
      s->rx.tail = 0;
    }
    s->rx.holding--;
    retval = 1;
  }

  // initialise
  s->rx.tail = s->rx.head = s->rx.holding = 0;





 
Yahoo! Groups Links

Circular buffers

2004-03-04 by Owen Mooney

Circular buufers are a technique not routines

Typical psuedocode:

    buffer[1024];
    int onpointer=0,offpointer=0;

    procedure addbyte(data) {
          buffer[onpointer]=data;
          onpointer++;
          onpointer= onpointer & 1023;
    }

    function getbyte() {
          res
          if (onpointer==offpointer)
                 return 0;   // no data available
          res=buffer[offpointer];
          offpointer++;
          offpointer=offpointer & 1023
          ret res;
     }

onpointer alwasy points the the first avaliable free space. offpointer 
always points to the next item avaliable

Owen
Show quoted textHide quoted text
>Message: 11
>   Date: Wed, 3 Mar 2004 22:59:44 -0800
>   From: "Curt Powell" <curt.powell@...>
>Subject: Circular buffers
>
>Can someone point me to some circular buffer routines?
> 
>TIA,
> 
>Curt
> 
>
>  
>

RE: [lpc2000] Re: Circular buffers

2004-03-04 by Robert Adsett

At 11:57 AM 3/4/04 -0800, you wrote:
>Charles,
>
>Do you find this version to be "thread safe" when a UART ISR is filling
>it and the main program is processing (i.e. emptying) it?
>
>Curt

It could be made so but it's not as it is written.

Robert

" 'Freedom' has no meaning of itself.  There are always restrictions,
be they legal, genetic, or physical.  If you don't believe me, try to
chew a radio signal. "

                         Kelvin Throop, III

Re: Circular buffers

2004-03-04 by embeddedjanitor

--- In lpc2000@yahoogroups.com, "Curt Powell" <curt.powell@s...> 
wrote:
> Charles,
> 
> Do you find this version to be "thread safe" when a UART ISR is 
filling
> it and the main program is processing (i.e. emptying) it?
> 

No this is just the circular buffer itself. I normally wrap 
the "foreground" code in interrupt enable/disable code to make it 
interrupt safe.

Re: [lpc2000] Circular buffers

2004-03-04 by Peter Kuhar

I belive this is te best way to do it. Using linked list is to
procesor and memory consumnig. If you use add byte only in interrupt
rutine and getbyte only in main program it's considered to be "thread
safe"
Show quoted textHide quoted text
> Circular buufers are a technique not routines

> Typical psuedocode:

>     buffer[1024];
>     int onpointer=0,offpointer=0;

>     procedure addbyte(data) {
>           buffer[onpointer]=data;
>           onpointer++;
>           onpointer= onpointer & 1023;
>     }

>     function getbyte() {
>           res
>           if (onpointer==offpointer)
>                  return 0;   // no data available
>           res=buffer[offpointer];
>           offpointer++;
>           offpointer=offpointer & 1023
>           ret res;
>      }

> onpointer alwasy points the the first avaliable free space. offpointer
> always points to the next item avaliable

> Owen

>>Message: 11
>>   Date: Wed, 3 Mar 2004 22:59:44 -0800
>>   From: "Curt Powell" <curt.powell@...>
>>Subject: Circular buffers
>>
>>Can someone point me to some circular buffer routines?
>> 
>>TIA,
>> 
>>Curt
>> 
>>
>>  
>>





 
> Yahoo! Groups Links

Re: [lpc2000] Circular buffers

2004-03-04 by Robert Adsett

At 10:55 PM 3/4/04 +0100, you wrote:
>I belive this is te best way to do it. Using linked list is to
>procesor and memory consumnig. If you use add byte only in interrupt
>rutine and getbyte only in main program it's considered to be "thread
>safe"
It's not thread safe.  It'll work in a cooperative tasking environment but 
not in a pre-emptive or interrupt environment w/o further protection.

It's also missing overflow protection but that's a different issue.

It's fine as an illustration of the general concept though which is what is 
was presented as.

Robert


" 'Freedom' has no meaning of itself.  There are always restrictions,
be they legal, genetic, or physical.  If you don't believe me, try to
chew a radio signal. "

                         Kelvin Throop, III

Re: Circular buffers

2004-03-05 by embeddedjanitor

This method has one problem.
If the buffer fills up, then previous contents will get lost.
ie. If you add 1024 bytes before taking any off then onpointer will 
be the same as offpointer and the whole buffer will be lost.

It does, however, look threadsafe (well interrupt safe anyway) and 
will be fine so long as you don't get too far behind.


--- In lpc2000@yahoogroups.com, Peter Kuhar <peter.kuhar@g...> wrote:
> I belive this is te best way to do it. Using linked list is to
> procesor and memory consumnig. If you use add byte only in interrupt
> rutine and getbyte only in main program it's considered to 
be "thread
> safe"
> > Circular buufers are a technique not routines
> 
> > Typical psuedocode:
> 
> >     buffer[1024];
> >     int onpointer=0,offpointer=0;
> 
> >     procedure addbyte(data) {
> >           buffer[onpointer]=data;
> >           onpointer++;
> >           onpointer= onpointer & 1023;
> >     }
> 
> >     function getbyte() {
> >           res
> >           if (onpointer==offpointer)
> >                  return 0;   // no data available
> >           res=buffer[offpointer];
> >           offpointer++;
> >           offpointer=offpointer & 1023
> >           ret res;
> >      }
> 
> > onpointer alwasy points the the first avaliable free space. 
offpointer
Show quoted textHide quoted text
> > always points to the next item avaliable
> 
> > Owen
> 
> >>Message: 11
> >>   Date: Wed, 3 Mar 2004 22:59:44 -0800
> >>   From: "Curt Powell" <curt.powell@s...>
> >>Subject: Circular buffers
> >>
> >>Can someone point me to some circular buffer routines?
> >> 
> >>TIA,
> >> 
> >>Curt
> >> 
> >>
> >>  
> >>
> 
> 
> 
> 
> 
>  
> > Yahoo! Groups Links

Re: [lpc2000] Re: Circular buffers

2004-03-05 by Robert Adsett

At 04:01 AM 3/5/04 +0000, you wrote:
>This method has one problem.
>If the buffer fills up, then previous contents will get lost.
>ie. If you add 1024 bytes before taking any off then onpointer will
>be the same as offpointer and the whole buffer will be lost.

I'd check for it myself.  If a large buffer overflows it's worth knowing 
about since it may indicate the receiver process is starving and for a 
small buffer it may be essential to limit the data loss at high 
throughput.  If you wanted to get fancy you could add some sort of 
throttling logic.


>It does, however, look threadsafe (well interrupt safe anyway) and
>will be fine so long as you don't get too far behind.

You're right.  I had misread the test in the read routine.  As long as you 
don't try to do something like add multiple producers and consumers (and 
why would you for a serial routine), it'll be fine.

Robert

" 'Freedom' has no meaning of itself.  There are always restrictions,
be they legal, genetic, or physical.  If you don't believe me, try to
chew a radio signal. "

                         Kelvin Throop, III

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.