rtel wrote on Tuesday, January 18, 2005:
> I’m running into some trouble, trying to get freertos running on a pic18F8525.
> First: the program restarts over an over again. I found out that the (hardware)
> stack overflow bit was set after a reset, so there is definitely something
Sorry to state the obvious - but have you disabled the hardware watchdog if there is such a thing on the 18f8525?
The 8525 has more RAM than the 452 - on which the port was produced - so we should be able to get it running.
If you are not already doing so then… to start with just try getting a hello world type application running - create a single task that flashes an LED for example - using the cooperative scheduler (set portUSE_PREEMPTION to 0) is also a good idea at the start as it makes stepping through the code much easier.
> In one situation I noticed that when restoring the first task to run (in
> startScheduler) the restored INTCON had the global interrupt bit diabled!, so
> I guess something is wrong in saving or restoring process context.
If this is the first task to execute then this is very strange. When the task is created a chunk of memory is grabbed for the task stack, and the initial stack is setup. When the task starts it restores it’s stack from that memory so if it is being restored with a value other than 0xc0 in INTCON then either the memory has been corrupted prior to the task starting - or memory was never allocated in the first place.
Have you checked the return value of sTaskCreate() when you create your task?
> Secondly, when I enabled debugging, I received an error message stating that
> the hex file format wouldn’t allow addressing beyond 64kbytes. Since the ROM
> is only 48kbytes, this should not be a problem. enabling the suggested INHX32
> format ‘solves’ this problem, but I’m concerned the program is now stored partly
> in non-existent memory.
Check the .map file - this will tell you if this is the case. I doubt there is a problem otherwise you would expect linking to fail but you never know.
> The stack is also not clear to me.
> Is there a hardware stack, a software stack and a freertos context stack?
Each task maintains it’s own software stack space - but while executing the compiler uses the hardware stack also. When a task is switched out the hardware stack is copied onto it’s own software stack to prevent it getting clobbered by the next task. Likewise when the task starts again it copies the saved hardware stack values from the software stack back onto the hardware stack.
> Otherwise I do not see how you fit so many tasks which each require
> portMINIMAL_STACK_SIZE (105 according to portmacro.h , 0xa5=165 according to
> the FAQ:how big should the stack be, which is it?)
The value of portMINIMAL_STACK_SIZE is actually different for every port - hence it’s location in the portmacro.h file. Maybe this needs to be made clearer in the FAQ.
If you are still having problems with a simple hello world type program then maybe I can give it a go in the MPLAB simulator.