[En-Nut-Discussion] Thread Switching Problem
Ralph Mason
ralph.mason at telogis.com
Wed Apr 4 21:15:49 CEST 2007
I guess it’s a problem in your TCPservice function.
-----Original Message-----
From: en-nut-discussion-bounces at egnite.de
[mailto:en-nut-discussion-bounces at egnite.de] On Behalf Of MUHAMMAD AZEEM
AZAM
Sent: 05 April 2007 02:45
To: en-nut-discussion at egnite.de
Subject: [En-Nut-Discussion] Thread Switching Problem
I have the following code and my thread is not switching from main() to
Compute() Thread except for the first time. All threads have same priority.
Service thread is a TCP reuest Thread.
THanks for help in advance
Bye
------------------
THREAD(service_thread, arg)
{
//NutThreadSetPriority(61);
for (;;)
{
PORTD = PORTD & 0xfe;
//DDRD = 0xff;
//PORTD = 0x00;
TCPservice();
PORTD = PORTD | 0x01;
//DDRD = 0xff;
//PORTD = 0xff;
}
}
THREAD(compute_thread, arg)
{
//NutThreadSetPriority(65);
for (;;)
{
NutSleep(500);
PORTD = PORTD & 0xfd;
NutSleep(500);
PORTD = PORTD | 0x02;
//DDRD = 0xff;
//PORTD = 0x0f;
//NutSleep(1000);
}
}
/***************************************************************************
***********
****************************** Initialization Functions
*******************************
****************************************************************************
**********/
void InitRegisterDevice(void)
{
NutRegisterDevice(&devEth0, 0x8300, 5);
}
int InitEthernetDevice(void)
{
u_long ip_addr = inet_addr(MY_IPADDR);
u_long ip_mask = inet_addr(MY_IPMASK);
u_char mac[6] = MY_MAC;
NutNetIfConfig("eth0", mac, ip_addr, ip_mask);
return 0;
}
/***************************************************************************
***********
*********************************** Main
**********************************************
****************************************************************************
**********/
int main(void)
{
static char txt_msg0_str[] = "TCP Server \x0";
static char txt_msg1_str[] = "Ethernut Project\x0";
/***************************************************
* LED & LCD initialization
*****************************************************/
DevBoardShiftLedOut(ShiftLEDOut);
strcpy(LCDText,txt_msg0_str);
strcat(LCDText,txt_msg1_str);
LCD_Init();
LCD_Cursor_YX( 0, 0 );
LCD_Puts(txt_msg0_str);
LCD_Cursor_YX( 1, 0 );
LCD_Puts(txt_msg1_str);
LCD_SendCmd(0x0C); /* display on, cursor off */
//----------------------------------
InitRegisterDevice();
if (InitEthernetDevice() == 0)
{
NutThreadCreate("NET_Thread", service_thread, 0, 512);
NutThreadCreate("OTH_Thread", compute_thread, 0, 512);
//NutThreadSetPriority(254); /*smallest priority on main program.
Default priority is 64*/
for (;;)
{
NutSleep(1000);
PORTD = PORTD & 0xfb;
NutSleep(1000);
PORTD = PORTD | 0x04;
//DDRD = 0xff;
//PORTD = 0xf0;
//NutSleep(500);
}
}
return 0;
}
-----------------------
---------------------------------
Bored stiff? Loosen up...
Download and play hundreds of games for free on Yahoo! Games.
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion
--
Internal Virus Database is out-of-date.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.15.9/573 - Release Date: 05/12/2006
16:07
--
Internal Virus Database is out-of-date.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.15.9/573 - Release Date: 05/12/2006
16:07
More information about the En-Nut-Discussion
mailing list