Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

small schedduler for pic12c508

Status
Not open for further replies.

gorkin

Advanced Member level 1
Joined
Feb 27, 2002
Messages
422
Helped
13
Reputation
26
Reaction score
5
Trophy points
1,298
Location
brazil
Activity points
3,375
Hi brothers! I need implement the following code in small PIC12C508.
I teste with sucessifull in others devices like PIC12F629 and PIC16F627, but when I compile for PIC12C508 the code not run correctly, anyone have any suggestion?
Thanks a lot and have a nice day or night! :wink:

#include <stdlib.h>
#include <stdio.h>

#define ON 0
#define OFF 1

#define maxtasks 3

#define uchar unsigned char

// Variáveis Globais
uchar tasks = 0;
// Array de tasks, terminador null
void(*x[maxtasks + 1])(void);
// ponteiro de função
typedef void(*fp)(void);
//protótipos
uchar FindTask (void(*fp)(void));
void CreateTask (void(*task)(void));
void DeleteTask (void(*fp)(void));
void task0 (void);
void task1 (void);
void task2 (void);
void task3 (void);
void task4 (void);
void task5 (void);

void CreateTask(void(*task)(void))
{
uchar n;

if(!FindTask(task))
{
for(n = 0x00; n < maxtasks || x[n] != NULL; n++)
{
if(x[n] == NULL)
{
x[n] = task;
x[++n] = NULL;
return;
}
}
}
}

void DeleteTask(void(*task)(void))
{
uchar n;

for(n = 0x00; n < maxtasks; n++)
{
if(x[n] == task)
{
do
{
x[n] = x[n + 0x01];
n++;
}
while(x[n] != NULL);
return;
}
}
}


uchar FindTask(void(*fp)(void))
{
uchar n;
uchar tmp;

for(n = 0x00; n < maxtasks || x[n] != NULL; n++)
{
if(x[n] == fp)
{
tmp = 0x01;
}
else
{
tmp = 0x00;
}
}
return(tmp);
}

void task0 (void)
{
#asm
NOP
NOP
NOP
NOP
NOP
#endasm
}

void task1 (void)
{
#asm
NOP
NOP
NOP
NOP
NOP
#endasm
}

void task2 (void)
{
#asm
NOP
NOP
NOP
NOP
NOP
#endasm
}

void task3 (void)
{
#asm
NOP
NOP
NOP
NOP
NOP
#endasm
}

void task4 (void)
{
}

void task5 (void)
{
}

void main (void)
{
uchar n = 0x00;

x[n] = NULL;
CreateTask(task0);
for(;;)
{
while(x[n] != NULL)
{
x[n++]();
}
n = 0x00;
}
}
 

Are you shure that it your program fits in 512 btyes??

otherwise .are you correctlt programming the watchdog timer and reset bits ??
 

Ok Elton, I simulate this code under MPLAB v6 and the C Compiler is Hitech...
When I compile this code, I report the memory map file, In ROM I use 55% and RAM 80%...
Strange...very strange no?

Thanks my brother!
Gorkin
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top