Pumpkin, Inc.

Pumpkin User Forums

Spilt the code

For issues specific to Microchip's PICmicro® MCUs, including compilers (e.g. HI-TECH PICC & PICC-18, Microchip MPLAB®-C18) and IDEs (e.g. Microchip MPLAB®).

Spilt the code

Postby aek » Fri Aug 06, 2004 12:33 am

Hi Teijo.

Your salvocfg.h configuration is the best you can do with Salvo on the 16F877, with its 96 bytes of available memory in each of Bank 2 and Bank 3.

What you've done is exactly what you must do to maximize the number of tasks you can run -- place only the tcbs in bank3 (or bank2, but not both).

Unfortunately, it's not possible to split the tcb's between two banks -- that's because of the way that the HI-TECH PICC bank2 and bank3 data memory qualifiers work, and the fact that there are SFRs from 0x180-0x18F.

Currently your tcbs are each 7 bytes long (13*7=91 (<96), 14*7=98 (>96)). With timeouts enabled, it's not possible to have smaller tcbs.

Disabling timeouts would allow you to run up to 16 tasks. You may want to consider that, but it's not easy to synthesize the timeout functionality on your own (I know of no way to do it).

Your best bet may simply be to upgrade your processor to a PIC18 ... it (e.g. PIC18F452) is pin-compatible with the PIC16F877A, and you won't have a limit on the number of tasks ...

I'm sorry I couldn't be of more help -- this is a real hardware limit you've come up against.

Regards,

------------------

[This message has been edited by aek (edited August 06, 2004).]

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: Spilt the code

Postby aek » Fri Aug 06, 2004 9:01 am

Hi Teijo.

Here are some ideas on adding the functionality of another task without exceeding 91 bytes of RAM in bank3:

1) If your lowest-priority task only calls OS_Delay() or OS_Yield(), you can probably turn it into a function and use it as the idling hook. #define OSIDLING_HOOK TRUE and the function will be called whenever there are no tasks eligible to run. Note that this function will look like

code:
void OSIdlingHook (void) // was void myLowestPrioTask (void)
{
do beginning;
do middle;
do end;
}

i.e. there is no longer an infinite loop nor an OS_Xyz() in it ...


2) Use a message in place of two or more binary semaphores. This will work if you have two or more tasks that wait for an event using a binSem, in the form

code:
void Task(void)
{
for (;;)
{
OS_WaitBinSem(...);
...
}
}

Instead of signaling one of two binSems, signal a message, and use the message contents to decide which action to take ... this will work if your existing program only requires one of the tasks to be running at the same time.

3) Consider "overlapping" tcbs. By this I mean that if you can identify two tasks that never run at the same time, you can replace one task by another using functions like OS_Replace().

------------------

[This message has been edited by aek (edited August 06, 2004).]

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: Spilt the code

Postby Tkk » Fri Aug 06, 2004 11:46 am

I have 13 tasks in my project with timeouts enabled. Ecb's are in bank2 and tcb's are in bank3. salvo.cgh looks like that:

#define OSENABLE_BINARY_SEMAPHORES TRUE
#define OSENABLE_MESSAGES TRUE
#define OSENABLE_TIMEOUTS TRUE
#define OSEVENTS 7
#define OSTASKS 13

#define OSLOC_ECB bank2
#define OSLOC_TCB bank3

there is no space in bank3 for more tasks. My question is: Is there any way to split code into several banks? Is 13 tasks maximum amount when timeouts are enabled? Is there any solution to move timeout counters into different bank?

I use salvo pro with hi-tech compiler and pic16f877a.

Best regards,

Teijo

Tkk
 
Posts: 6
Joined: Tue Jun 15, 2004 11:00 pm
Location: Oulu, Finland

Re: Spilt the code

Postby Tkk » Mon Aug 09, 2004 10:46 am

Thanks for the information! If i run code size problems then i might consider pic18.

regards,

Teijo

Tkk
 
Posts: 6
Joined: Tue Jun 15, 2004 11:00 pm
Location: Oulu, Finland


Return to PICmicro MCUs

Who is online

Users browsing this forum: No registered users and 3 guests

cron