# About porting FreeRTOS to general 80C51 MCU

**URL:** <https://forums.freertos.org/t/about-porting-freertos-to-general-80c51-mcu/2501>\
**Category:** Kernel\
**Created:** [March 10, 2005, 8:43am UTC](https://forums.freertos.org/t/about-porting-freertos-to-general-80c51-mcu/2501 "2005-03-10T08:43:07Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 10, 2005, 8:43am UTC](https://forums.freertos.org/t/about-porting-freertos-to-general-80c51-mcu/2501/1 "2005-03-10T08:43:07Z")

</div>

**nobody** wrote on [Thursday, March 10, 2005](https://sourceforge.net/p/freertos/discussion/382005/thread/6eca546c/#298f):

Nice to meet you all!  
Recently I am trying to port the FreeRTOS on some gerneral 80C51 Core based MCU with 2K External memory. I made referenced to the Cygnal 8051 based port. However, I find that I fail to run even a single task. I found that it fails in the pvPortMalloc(). I found that the following statement always false:  
if( ( usNextFreeByte + usWantedSize ) \< portTOTAL\_HEAP\_SIZE )

I am using the snapshot version of SDCC with the library for reenterant from FreeRTOS websites. I had modify the portSTACK\_START according to the MEM files generated by the SDCC. I had also modify the variables in portmacro.h. Any idea for this problems? Thank you~

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 10, 2005, 8:46am UTC](https://forums.freertos.org/t/about-porting-freertos-to-general-80c51-mcu/2501/2 "2005-03-10T08:46:23Z")

</div>

**nobody** wrote on [Thursday, March 10, 2005](https://sourceforge.net/p/freertos/discussion/382005/thread/6eca546c/#298f/5631):

To clarify, I also modify the port.c and using Timer 0 as the schedular. Thank you~

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 10, 2005, 8:45pm UTC](https://forums.freertos.org/t/about-porting-freertos-to-general-80c51-mcu/2501/3 "2005-03-10T20:45:32Z")

</div>

**nobody** wrote on [Thursday, March 10, 2005](https://sourceforge.net/p/freertos/discussion/382005/thread/6eca546c/#298f/a06c):

2K is not much to play with.

What is portTOTAL\_HEAP\_SIZE set to?&nbsp; Is there a memroy bank set up large enough to hold the entire array?&nbsp; Are there any warnings at link time?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 11, 2005, 1:28am UTC](https://forums.freertos.org/t/about-porting-freertos-to-general-80c51-mcu/2501/4 "2005-03-11T01:28:31Z")

</div>

**nobody** wrote on [Friday, March 11, 2005](https://sourceforge.net/p/freertos/discussion/382005/thread/6eca546c/#298f/869a):

The portTOTAL\_HEAP\_SIZE was set to 1500. The memory bank was set to 0 (so that except the R0-R7,all the others 256 bytes was used for SP, right?) There is no link warnings.

I had tried to implement some simple timer program to change the GPIO port(to flash LED)(without RTOS), everythings seems to be alright. The timer should be working fine.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 11, 2005, 1:31am UTC](https://forums.freertos.org/t/about-porting-freertos-to-general-80c51-mcu/2501/5 "2005-03-11T01:31:08Z")

</div>

**nobody** wrote on [Friday, March 11, 2005](https://sourceforge.net/p/freertos/discussion/382005/thread/6eca546c/#298f/a06c/cf82):

Anyway thanks for your help.  
In fact 2KBytes external memory , is that enough for 1x - 20 tasks for FreeRTOS? I am running the chip @ 40Mhz (12 Clocks for 1 intruction cycle).

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [March 11, 2005, 12:31pm UTC](https://forums.freertos.org/t/about-porting-freertos-to-general-80c51-mcu/2501/6 "2005-03-11T12:31:03Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Friday, March 11, 2005](https://sourceforge.net/p/freertos/discussion/382005/thread/6eca546c/#298f/a06c/4b22):

\>Is there a memroy bank set up large enough to hold the entire array?

I think you may be getting PIC and 8051 confused here.&nbsp;

The PIC port has the .lkr file in which the banking requires adjustment.&nbsp; That is not relevant here.

With the 8051 port the external RAM size is set in the makefile, using the --xram-size option.&nbsp; In the download this is set to 8448, and for 2K external RAM should be adjusted to 2048.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 11, 2005, 12:40pm UTC](https://forums.freertos.org/t/about-porting-freertos-to-general-80c51-mcu/2501/7 "2005-03-11T12:40:35Z")

</div>

**nobody** wrote on [Friday, March 11, 2005](https://sourceforge.net/p/freertos/discussion/382005/thread/6eca546c/#298f/dab9):

Hi,

If you look in the map file you should be able to see if the heap is allocated correctly.&nbsp; The variable you are looking for is xHeap.

For example, the map file for the cygnal build had the following section:

Area&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Addr&nbsp;&nbsp; Size&nbsp;&nbsp; Decimal Bytes (Attributes)  
--------------------------------&nbsp;&nbsp; ----&nbsp;&nbsp; ----&nbsp;&nbsp; ------- ----- ------------  
XSEG&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0000&nbsp;&nbsp; 18B9 =&nbsp;&nbsp; 6329. bytes (REL,CON,XDATA)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Value&nbsp; Global  
&nbsp;&nbsp; --------&nbsp; --------------------------------  
&nbsp; 0D:0000&nbsp;&nbsp;&nbsp; Ftasks$pxReadyTasksLists$0$0  
&nbsp; 0D:0058&nbsp;&nbsp;&nbsp; Ftasks$xDelayedTaskList1$0$0  
&nbsp; 0D:006E&nbsp;&nbsp;&nbsp; Ftasks$xDelayedTaskList2$0$0  
&nbsp; 0D:0084&nbsp;&nbsp;&nbsp; Ftasks$pxDelayedTaskList$0$0  
&nbsp; 0D:0087&nbsp;&nbsp;&nbsp; Ftasks$pxOverflowDelayedTaskList$0$0  
&nbsp; 0D:008A&nbsp;&nbsp;&nbsp; Ftasks$xPendingReadyList$0$0  
&nbsp; 0D:00A0&nbsp;&nbsp;&nbsp; LsTaskCreate$ucTaskNumber$1$1  
&nbsp; 0D:00A1&nbsp;&nbsp;&nbsp; Fheap\_1$xHeap$0$0  
&nbsp; 0D:18A5&nbsp;&nbsp;&nbsp; Fprint$xPrintQueue$0$0  
&nbsp; 0D:18A8&nbsp;&nbsp;&nbsp; LvStartPolledQueueTasks$xPolledQueue$1$1  
&nbsp; 0D:18AB&nbsp;&nbsp;&nbsp; Fserial$xRxedChars$0$0  
&nbsp; 0D:18AE&nbsp;&nbsp;&nbsp; Fserial$xCharsForTx$0$0  
&nbsp; 0D:18B1&nbsp;&nbsp;&nbsp; LsAreSemaphoreTasksStillRunning$sLastCheckVariables$1$1

[this will probably look a mess when pasted here as the spacing will be all wrong]

If you see the entry Fheap\_1$xHeap$0$0 you can see that it starts at A1 and ends at 18A5, so is approx 6K big.&nbsp; What do you see for these figures in your map file?

Also note my comments regarding the --xram-size setting within the makefile made in a different post.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 13, 2005, 1:23pm UTC](https://forums.freertos.org/t/about-porting-freertos-to-general-80c51-mcu/2501/8 "2005-03-13T13:23:53Z")

</div>

**nobody** wrote on [Sunday, March 13, 2005](https://sourceforge.net/p/freertos/discussion/382005/thread/6eca546c/#298f/dab9/fac5):

Thanks a lot for your help, the following would be my Mem location for XHeap function:  
Area&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Addr&nbsp;&nbsp; Size&nbsp;&nbsp; Decimal Bytes (Attributes)  
--------------------------------&nbsp;&nbsp; ----&nbsp;&nbsp; ----&nbsp;&nbsp; ------- ----- ------------  
XSEG&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0000&nbsp;&nbsp; 07BB =&nbsp;&nbsp; 1979. bytes (REL,CON,XDATA)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Value&nbsp; Global  
&nbsp;&nbsp; --------&nbsp; --------------------------------  
&nbsp; 0D:0000&nbsp;&nbsp;&nbsp; F\_\_\_\_\_\_Source\_tasks$pxReadyTasksLists$0$0  
&nbsp; 0D:0058&nbsp;&nbsp;&nbsp; F\_\_\_\_\_\_Source\_tasks$xDelayedTaskList1$0$0  
&nbsp; 0D:006E&nbsp;&nbsp;&nbsp; F\_\_\_\_\_\_Source\_tasks$xDelayedTaskList2$0$0  
&nbsp; 0D:0084&nbsp;&nbsp;&nbsp; F\_\_\_\_\_\_Source\_tasks$pxDelayedTaskList$0$0  
&nbsp; 0D:0087&nbsp;&nbsp;&nbsp; F\_\_\_\_\_\_Source\_tasks$pxOverflowDelayedTaskList$0$0  
&nbsp; 0D:008A&nbsp;&nbsp;&nbsp; F\_\_\_\_\_\_Source\_tasks$xPendingReadyList$0$0  
&nbsp; 0D:00A0&nbsp;&nbsp;&nbsp; LsTaskCreate$ucTaskNumber$1$1  
&nbsp; 0D:00A1&nbsp;&nbsp;&nbsp; F\_\_\_\_\_\_Source\_portable\_MemMang\_heap\_1$xHeap$0$0  
&nbsp; 0D:07AD&nbsp;&nbsp;&nbsp; F\_\_\_Common\_Full\_print$xPrintQueue$0$0  
&nbsp; 0D:07B0&nbsp;&nbsp;&nbsp; LvStartPolledQueueTasks$xPolledQueue$1$1  
&nbsp; 0D:07B3&nbsp;&nbsp;&nbsp; LsAreSemaphoreTasksStillRunning$sLastCheckVariables$1$1

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [March 13, 2005, 1:39pm UTC](https://forums.freertos.org/t/about-porting-freertos-to-general-80c51-mcu/2501/9 "2005-03-13T13:39:43Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Sunday, March 13, 2005](https://sourceforge.net/p/freertos/discussion/382005/thread/6eca546c/#298f/dab9/fac5/ee13):

Your print out shows that 1.75 KBytes have been allocated to the heap, which is good.&nbsp; It is odd then that the line:

if( ( usNextFreeByte + usWantedSize ) \< portTOTAL\_HEAP\_SIZE )

would return false.

usNextFreeByte should be initialsed to 0 - this is an initialised file scope variable which should be set to 0 before main() gets called.

usWantedSize is the parameter you pass in, which is presumably quite a small number (?).

And portTOTAL\_HEAP\_SIZE is your constant.

So how can this line fail?&nbsp; Can you step through the code to this point and look at the values of usWantedSize and usNextFreeByte.&nbsp;

The only thing I can think of is that usNextFreeByte is not being initialised properly or it is getting clobbered before you get to the function call.

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 13, 2005, 3:13pm UTC](https://forums.freertos.org/t/about-porting-freertos-to-general-80c51-mcu/2501/10 "2005-03-13T15:13:45Z")

</div>

**nobody** wrote on [Sunday, March 13, 2005](https://sourceforge.net/p/freertos/discussion/382005/thread/6eca546c/#298f/dab9/fac5/ee13/50ff):

Thank you. Richard. I will have another trial tonight.  
Another question, is that for my case, the following definition needed to be change:  
#define portMINIMAL\_STACK\_SIZE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ( ( unsigned portSHORT ) 200 - ( unsigned portSHORT ) portSTACK\_START )

if not, the size for those idle task would be quite large and 2K external memory seems cannot hold much tasks at the same time…thank you~

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 13, 2005, 3:15pm UTC](https://forums.freertos.org/t/about-porting-freertos-to-general-80c51-mcu/2501/11 "2005-03-13T15:15:15Z")

</div>

**nobody** wrote on [Sunday, March 13, 2005](https://sourceforge.net/p/freertos/discussion/382005/thread/6eca546c/#298f/a06c/4b22/3153):

Yes, I had already edit the makefile for --xram-size to 2048. Thanks a lot~

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 13, 2005, 4:56pm UTC](https://forums.freertos.org/t/about-porting-freertos-to-general-80c51-mcu/2501/12 "2005-03-13T16:56:06Z")

</div>

**nobody** wrote on [Sunday, March 13, 2005](https://sourceforge.net/p/freertos/discussion/382005/thread/6eca546c/#298f/dab9/fac5/ee13/59aa):

I have tried to add the following function call to the main in main.c  
vPortInitialiseBlocks();  
and I change the following  
#define portMINIMAL\_STACK\_SIZE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ( ( unsigned portSHORT ) 100 - ( unsigned portSHORT ) portSTACK\_START )

This makes the sTaskCreate 0x00 in return  
However, I still fail to run a single task, the task as follow:

static void prvToggleOnBoardLED2( void )  
{  
&nbsp;&nbsp;&nbsp; /\* If the on board LED is on, turn it off and visa versa. \*/  
&nbsp;&nbsp;&nbsp; if( P1 & 0x20 )  
&nbsp;&nbsp;&nbsp; {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; P1 &= ~0x20;  
&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp; else  
&nbsp;&nbsp;&nbsp; {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; P1 |= 0x20;  
&nbsp;&nbsp;&nbsp; }  
}  
/\*-----------------------------------------------------------\*/  
static void vToggleLED( void \*pvParameters )  
{  
&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp; (void)pvParameters;  
&nbsp;&nbsp;&nbsp; P1\_4=0;  
&nbsp;&nbsp;&nbsp; for(;😉  
&nbsp;&nbsp;&nbsp; {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; prvToggleOnBoardLED2();  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vTaskDelay(0xff);  
&nbsp;&nbsp;&nbsp; }  
}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 15, 2005, 7:22am UTC](https://forums.freertos.org/t/about-porting-freertos-to-general-80c51-mcu/2501/13 "2005-03-15T07:22:12Z")

</div>

**nobody** wrote on [Tuesday, March 15, 2005](https://sourceforge.net/p/freertos/discussion/382005/thread/6eca546c/#298f/b799):

Sorry for disturbing all of you again. I found that some static variables are not being initialised. Is that the lastest snapshot version of SDCC imcomplatible with the reenterant library?

If that is the fact, I may try to implement the freeRTOS by using Keil C.  
Thank you~

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 15, 2005, 8:23am UTC](https://forums.freertos.org/t/about-porting-freertos-to-general-80c51-mcu/2501/14 "2005-03-15T08:23:57Z")

</div>

**nobody** wrote on [Tuesday, March 15, 2005](https://sourceforge.net/p/freertos/discussion/382005/thread/6eca546c/#298f/bacd):

1 more question:  
When main() try to call sPortStartScheduler()  
if I have just one single task made, the pxCurrentTCB should be points to the TCB of that task or not? and the value stored inside the \*pxCurrentTCB should be the stack size (17 in this case?)

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 15, 2005, 9:18am UTC](https://forums.freertos.org/t/about-porting-freertos-to-general-80c51-mcu/2501/15 "2005-03-15T09:18:42Z")

</div>

**nobody** wrote on [Tuesday, March 15, 2005](https://sourceforge.net/p/freertos/discussion/382005/thread/6eca546c/#298f/b799/f1ef):

Is this the case when you try compiling a simple "hello world" type program?&nbsp; Maybe the variables are getting initialised, but then corrupted.

Can you look at the startup asm code to see where the initialisation should occur?

If you find that you get the same problem with a simple “hello world” program then try sending the program (it must be small and compile ‘out of the box’) to the sdcc support mail list.&nbsp; [http://sdcc.sourceforge.net](http://sdcc.sourceforge.net) has the list information.

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [March 15, 2005, 9:26am UTC](https://forums.freertos.org/t/about-porting-freertos-to-general-80c51-mcu/2501/16 "2005-03-15T09:26:15Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Tuesday, March 15, 2005](https://sourceforge.net/p/freertos/discussion/382005/thread/6eca546c/#298f/bacd/5d58):

You will actually have two tasks - because the idle task is created automatically - but the pxCurrentTCB should point to your task as you say.

\*pxCurrentTCB will not however be the stack size - but a pointer to the top of the task stack.

I suspect you may be getting some corruption somewhere.

I don’t know what your debug system is like.&nbsp; If you can stop the program where main() is called then take a look at the static variable values.&nbsp; If they are correct then you can step through until you see it change to the incorrect value.

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 15, 2005, 9:41am UTC](https://forums.freertos.org/t/about-porting-freertos-to-general-80c51-mcu/2501/17 "2005-03-15T09:41:49Z")

</div>

**nobody** wrote on [Tuesday, March 15, 2005](https://sourceforge.net/p/freertos/discussion/382005/thread/6eca546c/#298f/bacd/5d58/bb05):

Thank you Richard,

it is a pity for me to have just a 89C51SND1 , it is a 8051 based core chip running @ 20Mhz (X2 mode just need 6 clock period per instruction, thus act as a 8051 @ 40MHz)… I do not have any debug system except 2 leds…

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 15, 2005, 9:49am UTC](https://forums.freertos.org/t/about-porting-freertos-to-general-80c51-mcu/2501/18 "2005-03-15T09:49:23Z")

</div>

**nobody** wrote on [Tuesday, March 15, 2005](https://sourceforge.net/p/freertos/discussion/382005/thread/6eca546c/#298f/bacd/5d58/bb05/673d):

Hi,

void main( void )  
{  
----// First check if the variable starts with the  
----// expected value.  
----if( variable == expected value )  
--------Led1 = on;  
----else  
--------Led2 = on;

----// The rest of your code here  
}

The old fashioned way 🙂

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 15, 2005, 9:59am UTC](https://forums.freertos.org/t/about-porting-freertos-to-general-80c51-mcu/2501/19 "2005-03-15T09:59:26Z")

</div>

**nobody** wrote on [Tuesday, March 15, 2005](https://sourceforge.net/p/freertos/discussion/382005/thread/6eca546c/#298f/bacd/5d58/ef72):

"\*pxCurrentTCB will not however be the stack size - but a pointer to the top of the task stack. "

Yup, thank you for correcting my mistake 🙂

and \*(\*pxCurrentTCB) would be the stack size right?.. I should expected with default setting, I should get the value 17? thank you~

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 15, 2005, 10:05am UTC](https://forums.freertos.org/t/about-porting-freertos-to-general-80c51-mcu/2501/20 "2005-03-15T10:05:10Z")

</div>

**nobody** wrote on [Tuesday, March 15, 2005](https://sourceforge.net/p/freertos/discussion/382005/thread/6eca546c/#298f/bacd/5d58/bb05/673d/3730):

yup , I am now using this method… however, it must be the most troublesome way… as I cannot check for the stack pointer and the internal / external memory map.

I could just guess for my expect value ☹ . Some parts I would use some debug marco to swap out the whole byte for checking…

[Next page](https://forums.freertos.org/t/about-porting-freertos-to-general-80c51-mcu/2501.md?page=2)
