public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Re Problem with threads in the port for phyCORE MPC555
@ 2007-01-17  5:09 Asutosh Das
  0 siblings, 0 replies; 2+ messages in thread
From: Asutosh Das @ 2007-01-17  5:09 UTC (permalink / raw)
  To: ecos-discuss

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [ECOS] Re Problem with threads in the port for phyCORE MPC555
@ 2007-01-17  4:59 Asutosh Das
  0 siblings, 0 replies; 2+ messages in thread
From: Asutosh Das @ 2007-01-17  4:59 UTC (permalink / raw)
  To: ecos-discuss

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-01-17  5:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-17  5:09 [ECOS] Re Problem with threads in the port for phyCORE MPC555 Asutosh Das
  -- strict thread matches above, loose matches on Subject: below --
2007-01-17  4:59 Asutosh Das

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).