# Getting Start FreeRTOS

**URL:** <https://forums.freertos.org/t/getting-start-freertos/3146>\
**Category:** Kernel\
**Created:** [July 9, 2007, 5:32pm UTC](https://forums.freertos.org/t/getting-start-freertos/3146 "2007-07-09T17:32:29Z")\
**Posts on this page:** 18\
**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:** [July 9, 2007, 5:32pm UTC](https://forums.freertos.org/t/getting-start-freertos/3146/1 "2007-07-09T17:32:29Z")

</div>

**[scentoflove](https://sourceforge.net/u/scentoflove/)** wrote on [Monday, July 09, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/8a094aac/#4360):

Dear all!  
I’m a newbie with FreeRTOS, I have a project to use RTOS with PIC. I download FreeRTOS demo and compile successful, but I can’t understand demo’s logic, structure . Please tell me where I should begin. I think V1.0 is simplest but I can’t find it in download page so I use V2.4.2.

---

<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:** [July 9, 2007, 6:50pm UTC](https://forums.freertos.org/t/getting-start-freertos/3146/2 "2007-07-09T18:50:23Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Monday, July 09, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/8a094aac/#4360/5c7d):

V1.0 does not have a PIC port.&nbsp; I should stick to the latest version.

Have you read through the demo project and source code organisation sections of the [FreeRTOS.org](http://FreeRTOS.org) WEB site?&nbsp; Start there, along with stepping through the code in the MPALB simulator.

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 11, 2007, 3:15am UTC](https://forums.freertos.org/t/getting-start-freertos/3146/3 "2007-07-11T03:15:08Z")

</div>

**[scentoflove](https://sourceforge.net/u/scentoflove/)** wrote on [Wednesday, July 11, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/8a094aac/#4360/5235):

Thanks Richard. I have read the source code organisation and demo project code, but i can’t find which file contain the function vPortInitialiseBlocks is written.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 11, 2007, 6:02am UTC](https://forums.freertos.org/t/getting-start-freertos/3146/4 "2007-07-11T06:02:36Z")

</div>

**[pdeflandre](https://sourceforge.net/u/pdeflandre/)** wrote on [Wednesday, July 11, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/8a094aac/#4360/c881):

I don’t know for the PIC port, but for at91sam7x the vPortInitialiseBlocks is in ./Source/portable/MemMang/heap\_1.c

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 12, 2007, 3:04pm UTC](https://forums.freertos.org/t/getting-start-freertos/3146/5 "2007-07-12T15:04:16Z")

</div>

**[scentoflove](https://sourceforge.net/u/scentoflove/)** wrote on [Thursday, July 12, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/8a094aac/#4360/646f):

I compile with 18F452 is successful, but i compile with 18F458, 4520 is unsuccessful.  
If I want to create my project which file is necessary to include in my new project

---

<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:** [July 12, 2007, 5:50pm UTC](https://forums.freertos.org/t/getting-start-freertos/3146/6 "2007-07-12T17:50:47Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Thursday, July 12, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/8a094aac/#4360/646f/03a4):

In what way is it unsuccessful?&nbsp; The most likely problem is with the linker file.&nbsp; The demo creates one large RAM block, you would need to do the same for any other device variant used.

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 13, 2007, 3:04am UTC](https://forums.freertos.org/t/getting-start-freertos/3146/7 "2007-07-13T03:04:19Z")

</div>

**[scentoflove](https://sourceforge.net/u/scentoflove/)** wrote on [Friday, July 13, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/8a094aac/#4360/2549):

Error - section ‘.udata\_heap\_1.o’ can not fit the section. Section ‘.udata\_heap\_1.o’ length=0x00000404. I choosed correct linker file with device and 18F452 458 4520 have the same RAM.

Thanks Richard for reply

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 13, 2007, 8:35pm UTC](https://forums.freertos.org/t/getting-start-freertos/3146/8 "2007-07-13T20:35:10Z")

</div>

**[davedoors](https://sourceforge.net/u/davedoors/)** wrote on [Friday, July 13, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/8a094aac/#4360/2549/2483):

This is a linker problem.&nbsp; As Richard implied, you need to edit the linker script to create a block large enough to hold the entire heap.&nbsp; Look at the linker script in the download to see how it is done, then make the same changes to the linker script you are using.&nbsp; Alternatively, edit the linker script from the download to be correct for your PIC memory map.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 15, 2007, 8:28am UTC](https://forums.freertos.org/t/getting-start-freertos/3146/9 "2007-07-15T08:28:40Z")

</div>

**[scentoflove](https://sourceforge.net/u/scentoflove/)** wrote on [Sunday, July 15, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/8a094aac/#4360/b498):

Thanks all, I compiled successfull with 458.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 16, 2007, 5:12pm UTC](https://forums.freertos.org/t/getting-start-freertos/3146/10 "2007-07-16T17:12:46Z")

</div>

**[scentoflove](https://sourceforge.net/u/scentoflove/)** wrote on [Monday, July 16, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/8a094aac/#4360/473d):

Now I have a problem. I creates task1 flash one led in pin 3 portb, the demo ran successful. If I created task2 flash one led in pin 2 portb, the demo wouldn’t run.

Here is code

In void main ()

&nbsp;&nbsp;&nbsp; xTaskCreate( vTask1, ( const portCHAR \* const ) "Task1", configMINIMAL\_STACK\_SIZE, NULL, mainTASK1\_PRIORITY, NULL );  
&nbsp;&nbsp;&nbsp; xTaskCreate( vTask2, ( const portCHAR \* const ) "Task2", configMINIMAL\_STACK\_SIZE, NULL, mainTASK2\_PRIORITY, NULL );

Function task1

static void vTask1( void \*pvParameters )  
{  
&nbsp;&nbsp;&nbsp; portTickType xDelayTick = 200 ;  
&nbsp;&nbsp;&nbsp; LATBbits.LATB3=0;  
&nbsp;&nbsp;&nbsp; for ( ;; )  
&nbsp;&nbsp;&nbsp; {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LATBbits.LATB3=!LATBbits.LATB3;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vTaskDelay( xDelayTick );  
&nbsp;&nbsp;&nbsp; }  
}

Function task2

The same with task1, but pin 3 was replaced by pin 2.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 16, 2007, 5:25pm UTC](https://forums.freertos.org/t/getting-start-freertos/3146/11 "2007-07-16T17:25:48Z")

</div>

**[embeddedc](https://sourceforge.net/u/embeddedc/)** wrote on [Monday, July 16, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/8a094aac/#4360/473d/0282):

You did not say what it is that does not work.

Both of your tasks are writing to LATBbits which means you will get race conditions unless you use some protection mechanism.&nbsp; This might make the LED some time not flash as expected but I would not expect this to stop the whole application from working.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 17, 2007, 10:31am UTC](https://forums.freertos.org/t/getting-start-freertos/3146/12 "2007-07-17T10:31:23Z")

</div>

**[scentoflove](https://sourceforge.net/u/scentoflove/)** wrote on [Tuesday, July 17, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/8a094aac/#4360/8861):

In demo have the errorcheck tasks and I created 2 tasks. When I created only task1 (the demo have 2 tasks), the led flashed every 200ms and the demo’s check led flashed every 1s. If I created 2 tasks (the demo have 3 tasks), no led flashed.  
I changed the task2 to use the LATDbits but the demo didn’t run. I comment (//xTaskCreate( vErrorChecks, … ) the errorcheck task (the demo have 2 task task 1 & 2) it is running properly.  
I think not enough RAM for PIC to run (1426/1533bytes RAM).

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 25, 2007, 3:15pm UTC](https://forums.freertos.org/t/getting-start-freertos/3146/13 "2007-07-25T15:15:05Z")

</div>

**[scentoflove](https://sourceforge.net/u/scentoflove/)** wrote on [Wednesday, July 25, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/8a094aac/#4360/d433):

No reply for me :(! Now I’m working with dsPIC33FJ256GP710 and Explorer16. I can’t find function config OSC for pic so I use my function to setup OSC at the beginning of main function.

&nbsp;&nbsp; #define configCPU\_CLOCK\_HZ&nbsp;&nbsp;&nbsp; ( ( unsigned portLONG ) 80000000 )&nbsp; /\* Fosc / 2 \*/

&nbsp;&nbsp; OSCCON = 0x0180;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // fast rc, pll enable, clock lock  
&nbsp;&nbsp; OSCTUN = 23;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // 7.37MHz + 23 \* 0.375% = 8.00 MHz  
&nbsp;&nbsp; //CLKDIV = 0x0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // N1 = 2, N2 = 2  
&nbsp;&nbsp; \_PLLPRE=0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // N1 = 1  
&nbsp;&nbsp; \_PLLPOST=0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // N2 = 2  
&nbsp;&nbsp; PLLFBD = 38;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // M = 40 -\> Fosc = 8\*40/(2\*2)=80MHz, Fcy=40MIPs  
&nbsp;&nbsp; while(!OSCCONbits.LOCK); // wait untill clock stable

I have trouble with the loop while(!OSCCONbits.LOCK), the demo enter to infinite loop. I used this function in many projects before and working properly. Plz help me

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 25, 2007, 4:58pm UTC](https://forums.freertos.org/t/getting-start-freertos/3146/14 "2007-07-25T16:58:30Z")

</div>

**[scentoflove](https://sourceforge.net/u/scentoflove/)** wrote on [Wednesday, July 25, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/8a094aac/#4360/c3f3):

I comment the while loop (//while …), the demo working properly. When I create a new task and have a error.

code  
#define mainTASK1\_PRIORITY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ( tskIDLE\_PRIORITY + 4 )  
#define mainTASK1\_STACK\_SIZE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ( configMINIMAL\_STACK\_SIZE \* 2 )  
static void vCheckTask( void \*pvParameters );  
static void vTask1 (void \*pvParameters);

in main() function  
…  
xTaskCreate( vCheckTask, ( signed portCHAR \* ) "Check", mainCHECK\_TASK\_STACK\_SIZE, NULL, mainCHECK\_TASK\_PRIORITY, NULL );  
xTaskCreate( vTask1, ( signed portCHAR \* ) "Task1", mainTASK1\_STACK\_SIZE, NULL, mainTASK1\_PRIORITY, NULL );  
…

error

jump\_table(.handle+0x4): undefined reference to `vTask1’  
jump\_table(.handle+0x6): undefined reference to `vTask1’  
E:\Dev\FreeRTOS\Demo\dsPIC\_MPLAB\main.o(.text+0x50): In function `main’:  
E:\Dev\FreeRTOS\Demo\dsPIC\_MPLAB\main.c:167: undefined reference to `vTask1’

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 25, 2007, 5:28pm UTC](https://forums.freertos.org/t/getting-start-freertos/3146/15 "2007-07-25T17:28:13Z")

</div>

**[sotd](https://sourceforge.net/u/sotd/)** wrote on [Wednesday, July 25, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/8a094aac/#4360/d433/2c8e):

Do you need to do this?&nbsp; Here is some code used outside of main() that sets up a fast clock.&nbsp; This is for PIC24 but the dsPIC equivalent is probably similar.

\_CONFIG2( POSCMOD\_HS & OSCIOFNC\_OFF & FCKSM\_CSDCMD & FNOSC\_PRIPLL & IESO\_ON );  
\_CONFIG1(JTAGEN\_OFF & GCP\_OFF & GWRP\_OFF & FWDTEN\_OFF);

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 25, 2007, 5:29pm UTC](https://forums.freertos.org/t/getting-start-freertos/3146/16 "2007-07-25T17:29:54Z")

</div>

**[sotd](https://sourceforge.net/u/sotd/)** wrote on [Wednesday, July 25, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/8a094aac/#4360/c3f3/5dc1):

Is vTask1 defined in main.c too?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 26, 2007, 7:49am UTC](https://forums.freertos.org/t/getting-start-freertos/3146/17 "2007-07-26T07:49:02Z")

</div>

**[scentoflove](https://sourceforge.net/u/scentoflove/)** wrote on [Thursday, July 26, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/8a094aac/#4360/3760):

Thanks sold for reply  
\_I config dspic’s osc with FRCPLL and the dspic’s FRC have 7.37MHz nominal frequency. II just config \_FOSCSEL(FNOSC\_FRCPLL);, i don’t know exactly not only frequency but also PLL -\> Fcy=?. This code just config the PLL and the FRC frequency.  
\_vtask1 create and define in main.c.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 27, 2007, 2:25pm UTC](https://forums.freertos.org/t/getting-start-freertos/3146/18 "2007-07-27T14:25:43Z")

</div>

**[scentoflove](https://sourceforge.net/u/scentoflove/)** wrote on [Friday, July 27, 2007](https://sourceforge.net/p/freertos/discussion/382005/thread/8a094aac/#4360/3743):

Hi all.  
I extracted the FreeRTOSv4.3.1 again and I used the demo project to create 3 tasks to flash 3 leds with frequency 2Hz 1Hz 0.5Hz in portD and it’s working. I created my project with the same main.c and didn’t add demo standards files (BlockQ.h, … & commented #include BlockQ.h … in main.c ) it’s not work and suspended in vTaskDelay

Code flash led  
void vTask (void \*pvParameters )  
{  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \_TRISD1=0;  
&nbsp;&nbsp;&nbsp; \_LATD1=0;  
&nbsp;&nbsp;&nbsp; for ( ;; )  
&nbsp;&nbsp;&nbsp; {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vTaskDelay(500);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \_LATD1=!\_LATD1;  
&nbsp;&nbsp;&nbsp; }  
}
