This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Strange Problem in cyg_thread_delay( )?



My code listed as bellow:


****************************************************************************
**************************
****************************************************************************
**************************
#define IOPDATA   ((volatile unsigned *)(0x03FF5008))   // define the LED
PORT address



#include <cyg/kernel/kapi.h>

void delay(int cnt);        // delay routine

cyg_thread thread_s;
char stack[4096];
cyg_handle_t LED_thread;
cyg_thread_entry_t LED_program;
int dispcnt;            // display counter

void cyg_user_start(void)
{
        cyg_thread_create(4,LED_program, (cyg_addrword_t) 0, "LED Thread",
(void *) stack,4096, &LED_thread, &thread_s);
        dispcnt = 0;
        *IOPDATA = 0x00;                    // clear display of the LED
(note: bit4~bit7 represent the LED1~LED4 on the   ARM Evaluator7T board)
        delay(20);                                      // manual delay
        cyg_thread_resume(LED_thread);      // resume the led thread
}


void LED_program(cyg_addrword_t data)
{      
        for(;;)
        {
                if(dispcnt>=16)         // ensure the display counter not exceed 4-bit. (value 15)(we got 4 led on  the evaluator7T board so 4 bits)
                        dispcnt = 0;


                switch(dispcnt)
                {

                case 0:
                        *IOPDATA = 0x00;                 // bit4~bit7 as the LED1~LED4 on the Evaluator7T board
                        break;
                case 1:
                        *IOPDATA = 0x10;                //bit4~bit7 as the LED1~LED4 on the Evaluator7T board
                        break;
                case 2:
                        *IOPDATA = 0x20;                //bit4~bit7 as the LED1~LED4 on the Evaluator7T board
                        break;
                case 3:
                        *IOPDATA = 0x30;                //bit4~bit7 as the LED1~LED4 on the Evaluator7T board
                        break;
                case 4:
                        *IOPDATA = 0x40;
                        break;
                case 5:
                        *IOPDATA = 0x50;
                        break;
                case 6:
                        *IOPDATA = 0x60;
                        break;
                case 7:
                        *IOPDATA = 0x70;
                        break;
                case 8:
                        *IOPDATA = 0x80;
                        break;
                case 9:
                        *IOPDATA = 0x90;
                        break;
                case 10:
                        *IOPDATA = 0xa0;
                        break;
                case 11:
                        *IOPDATA = 0xb0;
                        break;
                case 12:
                        *IOPDATA = 0xc0;
                        break;
                case 13:
                        *IOPDATA = 0xd0;
                        break;
                case 14:
                        *IOPDATA = 0xe0;
                        break;
                case 15:
                        *IOPDATA = 0xf0;
                        break;
                }

                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;
        }
}

*************************************************************************************************
*************************************************************************************************


The LED comes to a 2 the halted forever. ( means it pass two cyg_thread_delay(200) then die)


===================================================================================================
===================================================================================================

-----Original Messa
ge-----
From: Andrew Lunn [mailto:andrew.lunn@ascom.ch]
Sent: 23 April 2001 12:08
To: Huang Qiang
Cc: eCos
Subject: Re: [ECOS] Strange Problem in cyg_thread_delay( )?


On Mon, Apr 23, 2001 at 12:03:05PM +0100, Huang Qiang wrote:
> Dear all:
>     I am using ARM Evaluator7T . My test program has a sigle thread
> runnning, while I call cyg_thread_delay(200) each time in the thread
(loop).
> It pass the first and second call to the cyg_thread_delay(200), but halted
> at the third call to the cyg_thread_delay. What's wrong with it? Can
anyone
> help me?
> Thanks a lot!
> james

Given the little information you have provided there could be lots of
possibilites....

Have you started the schedular?
Is your stack big enough?
Have you memset(0,0,10000);

Have you built eCos with assertions enables in package infra? That may
help.

Supply more details and then we may be able to help.

        Andrew


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]