This is the mail archive of the ecos-discuss@sourceware.org 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]
Other format: [Raw text]

Re Problem with threads in the port for phyCORE MPC555


Hi
I have downloaded a port for phyCORE mpc555. I could successfully build
it and I downloaded my code to the RAM section of the board. When I try
to run it, it switches to the other thread on the call of
cyg_thread_delay but exits the program after that.(attached below). 

The flow should be 1-2-3-1-3-1 and continue, but it does not and to my
surprise it exits and insight-gdb throws an exception SIGFPE Arithmetic
exception.

Please can anyone advise me on this?

#include<cyg/kernel/kapi.h>
#include "Main.h"

#define NUMBER_OF_THREADS    4
#define STACKSIZE     4096
static unsigned char stack[NUMBER_OF_THREADS][STACKSIZE];
static cyg_handle_t handle[NUMBER_OF_THREADS];
static cyg_thread   thread[NUMBER_OF_THREADS];


int main()
{
InitializeLED();

cyg_thread_create(2,SwitchRedLEDOn,0,"redLedOn", (void *)stack[0],
STACKSIZE, &handle[0],&thread[0]);
cyg_thread_create(3,SwitchRedLEDOff,0,"redLedOff", (void *)stack[1],
STACKSIZE, &handle[1],&thread[1]);

cyg_thread_resume(handle[0]);
cyg_thread_resume(handle[1]);
<------------------------------------------------- comes here 2nd and
resumes 2nd thread   (2)
return 0;
}<--------------------------------------------------------------------------------------------------------- but jumps back here (4)

void InitializeLED(void)
{
MPIOSMDR |= 0x0002;  /* drive MPIO1 high */
MPIOSMDR |= 0x0001;  /* drive MPIO0 high */
MPIOSMDDR |= 0x0003; /* configure MPIO0 and MPIO1 for output */
}

void SwitchRedLEDOn(cyg_addrword_t b)
{
while(1){
cyg_thread_delay(100);
<------------------------------------------- control comes here 1st
after 1st thread is resumed  (1)
MPIOSMDR &= 0xFFFD; /* drive MPIO1 low  */
}

}

void SwitchRedLEDOff(cyg_addrword_t a)
{
while(1){
MPIOSMDR |= 0x0002; /* drive MPIO1 high */
cyg_thread_delay(120);
<---------------------------------------------------------------- comes
here 3rd and thread gets blocked and should jump back to SwitchRedLEDOn
()  (3)
}
}

Regards
Asutosh Das
asutosh dot das at bsil dot com


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


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