From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Lunn To: Huang Qiang Cc: eCos Subject: Re: [ECOS] Strange Problem in cyg_thread_delay( )? Date: Tue, 24 Apr 2001 20:18:00 -0000 Message-id: <20010423151817.G2129@biferten.ma.tech.ascom.ch> References: X-SW-Source: 2001-04/msg00380.html 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 #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