public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew.lunn@ascom.ch>
To: Huang Qiang <jameshq@liverpool.ac.uk>
Cc: eCos <ecos-discuss@sources.redhat.com>
Subject: Re: [ECOS] Strange Problem in cyg_thread_delay( )?
Date: Tue, 24 Apr 2001 20:18:00 -0000	[thread overview]
Message-ID: <20010423151817.G2129@biferten.ma.tech.ascom.ch> (raw)
In-Reply-To: <KIEBICHBADHFCLGCKOPDCEFACBAA.jameshq@liv.ac.uk>

Hum, your code looks OK. As has already been mentioned on this list, 
what do the other bits in the register do?

Have you tried other values of delay? Does it run for longer? 

Are you a CS student at Liverpool Uni? I've edited your code a bit to
improve the style. I've moved some variables around, and replaced your
big case statemenet with a one liner. Lookup bitwise shift operations
in your C book. I've not checked this still compiles.

           Andrew

/* define the LED PORT address */
#include <cyg/kernel/kapi.h>

#define IOPDATA   ((volatile unsigned *)(0x03FF5008))   
#define STACKSIZE 4096

void delay(int cnt);        /* delay routine */

cyg_thread thread_s;
char stack[STACKSIZE];
cyg_handle_t LED_thread;
cyg_thread_entry_t LED_program;

void cyg_user_start(void)
{
  cyg_thread_create(4,LED_program, (cyg_addrword_t) 0, "LED Thread",
                    (void *) stack,STACKSIZE, &LED_thread, &thread_s);
  cyg_thread_resume(LED_thread);   /* resume the led thread */
}

void LED_program(cyg_addrword_t data)
{      
  unsigned dispcnt = 0;            /* display counter */
  
  *IOPDATA = 0x00;            /* clear display of the LED */
  delay(20);
  
  for(;;)
    {
      /* ensure the display counter not exceed 4-bit. (value 15)
         (we got 4 led on the evaluator7T board so 4 bits) */
      if (dispcnt>=16)         
        dispcnt = 0;
      
      *IOPDATA = ( dispcnt << 4);
      
      cyg_thread_delay(200); 
      dispcnt++;
    }
}

/* manual delay routine */

void delay(int cnt)
{
  int cnt1, cnt2, cnt3;

  for(cnt1=0;cnt1<40000;cnt1++)
    {
      for(cnt2=0;cnt2<cnt;cnt2++)
        cnt3 = 0;
    }
}

  reply	other threads:[~2001-04-24 20:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-23  4:46 Huang Qiang
2001-04-24 20:18 ` Andrew Lunn [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-04-23  5:24 Nielsen Linus
2001-04-23  4:02 Huang Qiang
2001-04-24 20:27 ` Andrew Lunn
2001-04-23  4:45   ` Huang Qiang
2001-04-26  2:43   ` Robert Cragie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010423151817.G2129@biferten.ma.tech.ascom.ch \
    --to=andrew.lunn@ascom.ch \
    --cc=ecos-discuss@sources.redhat.com \
    --cc=jameshq@liverpool.ac.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).