# [SOLVED]Microchip TCP/IP Stack - Helps Needed in Cooperate Multitasking

Status
Not open for further replies.

#### LongYC

##### Newbie level 2
Hi, I can't seem to make the Microchip stack works with a simple LED blinking program, I wish someone can give me an idea of what have I done wrong. Thank you.

Hardware:
PIC18F4620 with ENC28J60, the SPI is working fine, hardware components have no problem.

Compiler used:
C18, MPLAB deafult storage class is set to overlay.

Notes:
- Stack version: v5.31.
- The state constants are defined as 0x01, 0x02, etc. Tried '1', '2', etc, doesn't seem to be the problem.
- Everything works fine if I don't do it the cooperative multitasking way (no states) but it was too slow as tasks hogging the processor.

Code:
Code:
static unsigned char state;
static TICK time;

void main (void)
{
// ...... Initialize everything.

state = S_SET_DELAY;

while (1)
{
StackApplications();
MainApplication();
}
}

void MainApplication (void)
{
switch (state) {
case S_SET_DELAY:
time = TickGet();
state = S_DELAY_WAIT;
break;
case S_DELAY_WAIT:
if ( (TickGet() - time) >= 1*TICK_SECOND ) {
state = S_DELAY_DONE;
}
break;
case S_DELAY_DONE:
state = S_RUN_LED;
break;
case S_RUN_LED:
RUN_LED ^= 1;
state = S_SET_DELAY;
break;
default:
break;
}
}

By the way, I'm quite new in PIC microcntrollers as well as TCP/IP, is there any nice tutorial I can use? Especially about the Microchip TCP/IP stack. Thank you.

#### horace1

##### Advanced Member level 5
what exactly is your problem - are you missing TCP/UDP packets ? how much traffic is there?

I have used a PIC18F97J60 (which has an onboard Ethernet controller) with various devices attached (LCD, LEDs, barcode reader, RTC, IO extenders, etc) without problems. However, the traffic was low consisting of a data UDP packet transmiited every 10 seconds and a control UDP packet arriving a few times per hour.
If you have high traffic rates I would suggest moving to a PIC32MC6xx series.

if you do a web sreach for "microchip tcp ip stack tutorial" it will give you links to lots of information

#### LongYC

##### Newbie level 2
Turned out it was the ISR bug of the TickGet() but thank you for your reply anyway, for your willingness to help.

Status
Not open for further replies.

Replies
0
Views
3K
Replies
0
Views
1K
Replies
5
Views
4K
Replies
2
Views
3K
Replies
0
Views
701