FreeRTOS on HCS08

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FreeRTOS on HCS08

43,559 Views
jeffw
Contributor I
I've ported FreeRTOS to HCS08, and the project targets the SARD and EVB boards. I'm working on making SMAC compatible with this project.

Steps

1. Download and install FreeRTOS 3.2.4: FreeRTOS
2. Download the attached zip file
3. Unpack it into a temporary directory.
4. Following the FreeRTOS directory structure, move the sub-folders into their correct places.
5. Open the RTOSDemo.mcp project in CW 3.1.
6. Deploy to a Freescale SARD or EVB.

FreeRTOS-3.2.4-HCS08_Files.zip
Message Edited by dkindler on 2009-08-20 02:33 PM
Labels (1)
0 Kudos
Reply
149 Replies

1,220 Views
Phaled
Contributor I

Hello BlackNight,

I have used your 'queue.c' file and there is an error because the linker says this: Symbol ulPortSetIPL in file queue.o is undefined.

When delete this parts:

 

uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();

portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );

uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();

portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );

 

It works well. I want to know if I must keep them or delete them.

 

Thank for your answer

0 Kudos
Reply

1,220 Views
BlackNight
NXP Employee
NXP Employee

Hello,

Are you using an earlier version of the FreeRTOS component?

It looks so, as earlier versions did not correctly support the message queue API to be called within an ISR.

E.g. are using the xQueueSendToFrontFromISR() routines, then you need the new version I just had posted on 2011-07-13 10:34 AM. This one correctly supports the message queue handling within ISR's.

 

BK

 

0 Kudos
Reply

1,220 Views
BlackNight
NXP Employee
NXP Employee

Hello,

attached is the latest version of the FreeRTOS component.

This one supports the S08 banked memory model and has fixed the issue with using queues within an ISR.

 

BK

0 Kudos
Reply

1,220 Views
Stipey75
Contributor I

Thanks for the quick answer BK!!

 

Ok i'll try your procedure and then i will report my result....only one question, you say to give a look to QE128 port, but i can't see it in your files. Where can I find it?

 

thanks again

0 Kudos
Reply

1,220 Views
BlackNight
NXP Employee
NXP Employee

Hello,

the Processor Expert component in the port is for all S08, in principle for all ColdFire V1 (I have tested it with CN, JM, QE, JE and MM family) and the ColdFire V2 (tested with 52259). That's the advantage of the Processor Expert component port: one port to cover a lot of architectures :smileyhappy:

 

If you want to see the port files: they are in

C:\ProgramData\Processor Expert\CWMCU_PE5_00\Drivers\freeRTOS

after you have imported the Processor Expert component.

 

BK

0 Kudos
Reply

1,220 Views
LT
Contributor I

Hello, I have just started using freertos on a 9S08(GT60) using CW 6.2.

This is what I have:

3 tasks + 1 idle task.

Task1 : blocks for 100 ms using Vdelayuntil(). priority( idle+1)

Taks2:  blocks for 50 ms using  Vdelayuntil(). priority(idle+2)

Task3:  blocks for a binary semaphore.  priority(idle+3)

The semaphore is given by an interrupt generated by ( tim1 channel 1) every 100 ms. The interrupt rate is 10ms, and the TICKS_TO_WAIT is set to 10.

The RTOS tick is set at 1ms using tim1 channel 0 .

 

The problem:

When I have all three tasks running, the tasks are NOT running at their specified repeat rates. ( its all over the place).I am toggling an output pin in each of the tasks to determine the timing. 

If I remove task2, then task1 and task3 run at the specified repeat rates.

 

Will appreciate any help/hints to this problem.

 

 

Thanks!!

Lav 

 

 

 

// ------------------------------------------//

code snippets below

//---------------------------------//

 

*******************************************************************************
*
*
*
*******************************************************************************
*/
static void vTaskone( void *pvParameters )
{       
//    pvParameters = pvParameters;
    portTickType xLastWakeTime;
  const portTickType xFrequency = 100;
    // Initialise the xLastWakeTime variable with the current time.
     xLastWakeTime = xTaskGetTickCount();
    for( ;; )
    {
//#if !defined(_FCS_)
  // Wait for the next cycle.
         vTaskDelayUntil( &xLastWakeTime, xFrequency );
     PTDD_PTDD4 = ~PTDD_PTDD4;
//#endif
//        vTaskDelay(500);
    }
}


/*
*******************************************************************************
*
*
*
*******************************************************************************
*/
void vTaskTwo ( void *pvParameters )
{
  //    pvParameters = pvParameters;
  portTickType xLastWakeTime;
  const portTickType xFrequency = 50;
  // Initialise the xLastWakeTime variable with the current time.
  xLastWakeTime = xTaskGetTickCount();
    for (;:smileywink:
    {
//#if !defined(_FCS_)
vTaskDelayUntil( &xLastWakeTime, xFrequency );
//PTDD_PTDD3 = ~PTDD_PTDD3;
//#endif
//        vTaskDelay(250);
    }
}

*******************************************************************************
*
*
*
*******************************************************************************
*/
void vTaskThree ( void *pvParameters )
{
  //  pvParameters = pvParameters;
  /* We are using the semaphore for synchronisation so we create a binary
    semaphore rather than a mutex.  We must make sure that the interrupt
    does not attempt to use the semaphore before it is created! */
    vSemaphoreCreateBinary(tsk3_semphr);
    for (;:smileywink:
    {

/* We want this task to run every 30 ticks of a 10 ms timer.  The semaphore
   was created before this task was started.
       
        Block waiting for the semaphore to become available. */
        if( xSemaphoreTake( tsk3_semphr, LONG_TIME ) == pdTRUE )
        {
          PTDD_PTDD3 = ~PTDD_PTDD3;
        }
    }
}

*******************************************************************************
*
*
*
*******************************************************************************
*/

    if (xTaskCreate( vTaskone,   (const signed char *)"MyTaskone",   configMINIMAL_STACK_SIZE  , NULL, ( tskIDLE_PRIORITY + 1 ), NULL ) == pdFAIL)
    {
        for (;:smileywink:    __asm ("nop");
    }

    if (xTaskCreate( vTaskTwo,   (const signed char *)"MyTaskTwo",   configMINIMAL_STACK_SIZE,   NULL, ( tskIDLE_PRIORITY + 2 ), NULL ) == pdFAIL)
    {       
        for (;:smileywink:    __asm ("nop");
   }

    if (xTaskCreate( vTaskThree, (const signed char *)"MyTaskThree", configMINIMAL_STACK_SIZE,   NULL, ( tskIDLE_PRIORITY + 3 ), NULL ) == pdFAIL)
    {       
        for (;:smileywink:    __asm ("nop");

    }

 


0 Kudos
Reply

1,220 Views
bluehacker
Contributor III
I don't think running freertos on s08 mcu is a good idea. any serious rtos application need some larger memory,such as 32kB or above. there are not so much RAM  on s8 mcu, so I don't think the porting is meaningful. you can't only run two toy tasks on your porting. 
0 Kudos
Reply

1,220 Views
nonarKitten
Contributor II
The S08 has up to 60KB normally, and in a couple of cases, as much as 128KB, so an RTOS would be fine for it. I just compiled the FreeRTOS with USB stack and SMAC and it came up to a bit over 9KB for everything - that's pretty good, considering the SMAC is about 4KB of that, and the USB stack was another 2KB. So for most things, even a 16KB part would be fine, and it could probably run well on an 8KB part without SMAC and USB.
0 Kudos
Reply

1,220 Views
jeffw
Contributor I

There was a problem with the links in my original post.  I've since moved to a new web platform.  The files I originally posted are now here:

 

http://www.gadgetworks.com/?q=node/2

 

Tho' since that time there's been numerous changes and upgrades (I ported to FreeRTOS 4.x eons ago, but never posted that.)  I'm happy to post the project files that represent "current state of things" in HCS08+FreeRTOS if anyone has significantly changed the project in a useful way.  Just send me a message.  (Did someone get this running on S08?  I don't need that, but I'm curious.)

 

Jeff

0 Kudos
Reply

1,220 Views
rdavila
Contributor I
Alguien sabe si me puede servir el freeRTOS para el HC08 AP8 Family
0 Kudos
Reply

1,220 Views
Alban
Senior Contributor II
Hello rdavila,
 
Using an RTOS on a 8KB device is quite tricky because of the little RAM and little FLASH available.
 
The version on this thread is for HCS08 and not for HC08.
 
Cheers,
Alban.
0 Kudos
Reply

1,220 Views
Trenado
Contributor I
I just finished porting FreeRTOS to the 9S08JM60. The application is a simple USB CDC implementation using two tasks: one for the actual app, the other to manage the USB stuff.
 
You dont actually need an RTOS for the USB CDC but I just did it as a proof of concept for the company I work for.
 
I am using the same code base as the one posted here for the RTOS wich supports the HC08 and the S08 CPUs.
 
So, in case somebody is interested in this topic, you can use free rtos for both the HC08 and the S08 and you get a somewhat better performace using the newer S08 like the JM which runs with bus frequencies above 20Mhz.
 
Rene Trenado
 
 
0 Kudos
Reply

1,220 Views
ernesto_arc
Contributor II

hello, I use the jm60 with bootloader. I try for a few days with FreeRTOS but I have not been successful .. In the context changes and apparently lost the use asm in the port that is not right.

Could you share with your project? ...

0 Kudos
Reply

1,219 Views
mcolina_aimme_e
Contributor I

Dear Ernesto,

 

As I have no experience with the JM60 or its bootloader I cannot be of any help to you. Good luck!

 

Miguel.

0 Kudos
Reply

1,220 Views
ernesto_arc
Contributor II

hello,
this is my first attempt to carry the FreeRTOS to JM60. My concern is that you can live with USB Bootloader.

In this attempt, use the sample code mcolina@aimme.es. Thank you very much for sharing the code with all.

 

 

ProcessorExpert not use, because I want to be fully ANSI-C.

 

In some ways the FreeRTOS operates within the FLASH memory locations that do not overwrite the bootloader. Reflects the tasks to scheduled times, but do not understand the reason why if I want to control 2 LEDs, change out of the scheduled times.

Below is the compiled project in CodeWarrior 6.3. Could you please help me check where it may be the problem? ..

 

 

main.c

 

 

/********************************************************//********************************************************//*-------------- Espacio para funciones  ---------------*//********************************************************//* Standard includes. */#include <stdio.h>/* Scheduler includes. */#include "FreeRTOS.h"#include "task.h"#include "queue.h"#include "semphr.h"void led_task1(void *pvParameters){PTDDD_PTDDD2=1;   //Configura pin de control de LED como salida  for(;;){    PTDD_PTDD2=!PTDD_PTDD2;    vTaskDelay(1000 / portTICK_RATE_MS);       }}void led_task2(void *pvParameters){PTFDD_PTFDD5=1;   //Configura pin de control de LED como salida  for(;;){    PTFD_PTFD5=!PTFD_PTFD5;    vTaskDelay(2000 / portTICK_RATE_MS);       }}/********************************************************//********************************************************//*------------ Espacio de codigo principal -------------*//********************************************************/                       void main(void) {SOPT1 = 0x20;       //Deshabilita el modulo COP (WDT)xTaskCreate(  led_task1,               ( signed portCHAR * ) "Led1_blink",               configMINIMAL_STACK_SIZE, NULL,               tskIDLE_PRIORITY,               ( xTaskHandle * ) NULL );                            xTaskCreate(  led_task2,               ( signed portCHAR * ) "Led2_blink",               configMINIMAL_STACK_SIZE, NULL,               tskIDLE_PRIORITY,               ( xTaskHandle * ) NULL );                            vTaskStartScheduler(); //   EnableInterrupts;   for(;;){    }}//*******************************************************

 

I'm using the development system DEMOJM

 

0 Kudos
Reply

1,220 Views
BlackNight
NXP Employee
NXP Employee

Hello,

There is now CodeWarrior for MCU10.0 (eclipse based) available (see http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=CW-MCU10&tid=vancwmcu10).

 

Attached is a port based on the original port to S08 (see beginnig of this thread) plus the available port for V1 on www.freertos.org.

It is using eclipse with Processor Expert, so with this it is virtually working with any S08 and ColdFire V1.

The work is based on an university research project, and is presented at the FTF in Orlando (session ID FTF-ENT-F0539).

It encapsulates the latest FreeRTOS (6.0.5) as an embedded component, so you can create a project from scratch (Processor Expert enabled), and simply add the freeRTOS to your project, specify the timer module and SWI interrupt and you are ready to go.

The attached zip file contains the embedded component, two demo projects (one for S08 and one for QE128) plus a readme/installation guide. The demos are using doxygen too (there is the Eclox eclipse plugin you can download).

 

I hope this is useful. In any case, I plan to add other cores (like the S12 and the other ColdFires), so it should be really easy to use FreeRTOS with CodeWarrior under eclipse.

 

BK

0 Kudos
Reply

1,220 Views
BlackNight
NXP Employee
NXP Employee

Hello,

ups, I posted the .zip without the example projects, so here again.

 

BK

0 Kudos
Reply

1,219 Views
brauliochi_thin
Contributor I

Hy blacknight, when I try to put other thask in the project of coldfire v1 qe128, dont do it anything, you think that the problem is the memory ram is not to much?? best regards

0 Kudos
Reply

1,219 Views
brauliochi_thin
Contributor I

this is the code that I try to do

 

/** ###################################################################**     Filename  : ProcessorExpert.c**     Project   : ProcessorExpert**     Processor : MCF51QE128CLH**     Version   : Driver 01.00**     Compiler  : CodeWarrior ColdFireV1 C Compiler**     Date/Time : 03/07/2010, 10:58 p.m.**     Abstract  :**         Main module.**         This module contains user's application code.**     Settings  :**     Contents  :**         No public methods**** ###################################################################*//* MODULE ProcessorExpert *//* Including needed modules to compile this module/procedure */#include "Cpu.h"#include "Events.h"/* Include shared modules, which are used for whole project */#include "FRTOS1.h"#include "RTOSSWI1.h"#include "RTOSTMR1.h"#include "Term1.h"#include "Inhr2.h"#include "Bit1.h"#include "Bit2.h"#include "PE_Types.h"#include "PE_Error.h"#include "PE_Const.h"#include "IO_Map.h"static portTASK_FUNCTION(MyTask2,pvParameters){  (void)pvParameters; for(;;){  Bit2_NegVal();  //Term1_SendStr("Envio de tarea 2\r");      FRTOS1_vTaskDelay(500/portTICK_RATE_MS);    }}/* User includes (#include below this line is not maintained by Processor Expert) */static portTASK_FUNCTION(MyTask, pvParameters) {  (void)pvParameters; /* parameter not used */  FRTOS1_xTaskCreate(MyTask2,    (signed portCHAR *)"mytask2",    configMINIMAL_STACK_SIZE,    (void *)NULL,    1,    (xTaskHandle*)NULL);      for(;;) {   Bit1_NegVal();    //Term1_SendStr("Envio de tarea 1\r");    FRTOS1_vTaskDelay(500/portTICK_RATE_MS);  }}static void RTOS_Start(void) {  if (FRTOS1_xTaskCreate(      MyTask,  /* pointer to the task */      (signed portCHAR *)"MyTask", /* task name for kernel awareness debugging */      configMINIMAL_STACK_SIZE, /* task stack size */      (void*)NULL, /* optional task startup argument */      1,  /* initial priority */      (xTaskHandle*)NULL /* optional task handle to create */    )!=pdPASS)  {   //Term1_SendStr("Error1\r");  for(;;){}  }              FRTOS1_vTaskStartScheduler();}void main(void){  /* Write your local variable definition here */  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/  PE_low_level_init();  /*** End of Processor Expert internal initialization.                    ***/     /* Write your code here */  /* For example: for(;;) { } */  RTOS_Start();  /*** Don't write any code pass this line, or it will be deleted during code generation. ***/  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/  for(;;){}  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***//* END ProcessorExpert *//*** ###################################################################****     This file was created by Processor Expert 4.00 Beta [04.40]**     for the Freescale ColdFireV1 series of microcontrollers.**** ###################################################################*/

 

 

0 Kudos
Reply

1,220 Views
BlackNight
NXP Employee
NXP Employee

Hello,

not enough RAM for the heap is a common cause for task not created.

 

But I think your problem is a different one: you have your task code, but you do not add the task to the task list (xTaskCreate())?

 

You need to add in RTOS_Start() (or somewhere else) a call to xTaskCreate (see example for myTask in RTOS_Start()).

 

BK

0 Kudos
Reply

1,220 Views
brauliochi_thin
Contributor I

Yes, I created the task2 in to the task1, in the MyTask

see

 

static portTASK_FUNCTION(MyTask, pvParameters) {  (void)pvParameters; /* parameter not used */  FRTOS1_xTaskCreate(MyTask2,    (signed portCHAR *)"mytask2",    configMINIMAL_STACK_SIZE,    (void *)NULL,    1,    (xTaskHandle*)NULL);      for(;;) {   Bit1_NegVal();    //Term1_SendStr("Envio de tarea 1\r");    FRTOS1_vTaskDelay(300/portTICK_RATE_MS);  }}

 

 

But I try to create the task in the function RTOS_Start() and and yet it does not work, like this


 

/** ###################################################################**     Filename  : ProcessorExpert.c**     Project   : ProcessorExpert**     Processor : MCF51QE128CLH**     Version   : Driver 01.00**     Compiler  : CodeWarrior ColdFireV1 C Compiler**     Date/Time : 03/07/2010, 10:58 p.m.**     Abstract  :**         Main module.**         This module contains user's application code.**     Settings  :**     Contents  :**         No public methods**** ###################################################################*//* MODULE ProcessorExpert *//* Including needed modules to compile this module/procedure */#include "Cpu.h"#include "Events.h"/* Include shared modules, which are used for whole project */#include "FRTOS1.h"#include "RTOSSWI1.h"#include "RTOSTMR1.h"#include "Term1.h"#include "Inhr2.h"#include "Bit1.h"#include "Bit2.h"#include "PE_Types.h"#include "PE_Error.h"#include "PE_Const.h"#include "IO_Map.h"static portTASK_FUNCTION(MyTask2,pvParameters){  (void)pvParameters; for(;;){  Bit2_NegVal();  //Term1_SendStr("Envio de tarea 2\r");      FRTOS1_vTaskDelay(500/portTICK_RATE_MS);    }}/* User includes (#include below this line is not maintained by Processor Expert) */static portTASK_FUNCTION(MyTask, pvParameters) {  (void)pvParameters; /* parameter not used */      for(;;) {   Bit1_NegVal();    //Term1_SendStr("Envio de tarea 1\r");    FRTOS1_vTaskDelay(300/portTICK_RATE_MS);  }}static void RTOS_Start(void) {  if (FRTOS1_xTaskCreate(      MyTask,  /* pointer to the task */      (signed portCHAR *)"MyTask", /* task name for kernel awareness debugging */      configMINIMAL_STACK_SIZE, /* task stack size */      (void*)NULL, /* optional task startup argument */      1,  /* initial priority */      (xTaskHandle*)NULL /* optional task handle to create */    )!=pdPASS)  {   //Term1_SendStr("Error1\r");  for(;;){}  }    FRTOS1_xTaskCreate(MyTask2,      (signed portCHAR *)"mytask2",      configMINIMAL_STACK_SIZE,      (void *)NULL,      1,      (xTaskHandle*)NULL);              FRTOS1_vTaskStartScheduler();}void main(void){  /* Write your local variable definition here */  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/  PE_low_level_init();  /*** End of Processor Expert internal initialization.                    ***/     /* Write your code here */  /* For example: for(;;) { } */  RTOS_Start();    /*** Don't write any code pass this line, or it will be deleted during code generation. ***/  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/  for(;;){}  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***//* END ProcessorExpert *//*** ###################################################################****     This file was created by Processor Expert 4.00 Beta [04.40]**     for the Freescale ColdFireV1 series of microcontrollers.**** ###################################################################*/

 

How much task do you think I could created with 8kb of ram??? I dont know why dont works, because is a simple example, best regards

 

0 Kudos
Reply