JM and FreeRTOS

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

JM and FreeRTOS

12,294 Views
RajahMC
Contributor I
Does anyone have a FreeRTOS port for the JM128?

Thanks for your time,
Rajah
Labels (1)
0 Kudos
Reply
33 Replies

2,413 Views
wrljet
Contributor II

Thanks!  I will give it a try.

 

Bill

 

0 Kudos
Reply

2,413 Views
wrljet
Contributor II

Eduardo,

 

It's working.  Very nice.  And I love the way you rearranged the debugger windows.

I didn't know you could do that.

 

Bill

 

0 Kudos
Reply

2,413 Views
BSN
Contributor I

You are not serious about the debugger windows....

  It's to bad... Now that you said, I should have re-arranged that... :smileysad:

 

Eduardo

0 Kudos
Reply

2,413 Views
wrljet
Contributor II

I knew you could adjust their relative sizes, but never thought about a layout

like yours.  I do like the much larger source code window.

 

Do you have any gut feeling how much performance overhead the task switches take?

 

Bill

 

0 Kudos
Reply

2,413 Views
BSN
Contributor I

I believe it is not that much. I don't know right now to tell you exactely how you can do that with this IDE... But you can measure the context switch time using an oscilloscope and changing port pins values (LEDS...) when context switch occurs.

 

Eduardo


0 Kudos
Reply

2,413 Views
wrljet
Contributor II

Please excuse my ignorance of this whole topic, but here's an experiment I just ran.

 

To your existing two userTasks, I added a 3rd task:

 

void led2Task(void *pvParameters)
{
   (void) pvParameters;
   
     for( ;; ) {
        LED_4 = !LED_4;
        taskYIELD();
    }
}

 

Is that a valid experiment?

The LED toggles every 5.2us on the scope, while the other tasks continue to run normally.

 

Bill

 

0 Kudos
Reply

2,413 Views
BSN
Contributor I

Yes, of course it is valid - It is a good solution for that measurement. When you yield, the OS will check for tasks that are able to run. Beacause other tasks are all sleeping, that one is the only one able to run, with a priority higher then IDLE task. 

 

So, 5.2 us is the time it takes to switch context 

 

Eduardo

 

0 Kudos
Reply

2,413 Views
wrljet
Contributor II

Can this RTOS code work with Register calling convention?

 

Bill

 

0 Kudos
Reply

2,413 Views
BSN
Contributor I

Hi Bill.

 

I cannot "guarantee" you that, but I'm pretty sure YES, you can use Register ABI without any problems. That because the context of a task is totally preserved in a context switch. All the pointers (An), all the registers (Dn), SR, the stack,...  - everything is preserved.

 

I don't see any reason why using Reg ABI would not work.

 

Sorry for not answering before

 

Best Regards

 

Eduardo

0 Kudos
Reply

2,413 Views
BSN
Contributor I

Two small corrections for that file:

 

1 - Change in FreeRTOSConfig.h the processor frequency from 25000000 to 24000000

2 - Change in port.c, in the function  TickTimer_SetFreqH: 

      Set TPM1C0SC = 0x10   instead of  TPM1C0SC = 0x1C 

         Doing so will put ELS bits of TPM1C0SC to zero, and let PTE2 pin free as I/O (that pin is connected to LED1).

 

Eduardo


0 Kudos
Reply

2,413 Views
wrljet
Contributor II

Eduardo,

 

Thank you for those corrections.

 

I had found and changed the 24 MHz myself, and I forgot to mention that to you before.

 

For what it's worth, I'm soon going to try the FreeRTOS on my own hardware, a few pics

of which are here:

 

http://www.wrljet.com/junk/Eisbock-unstacked-circled.jpg

http://www.wrljet.com/junk/Eisbock-unstacked-ribbon.jpg

http://www.wrljet.com/junk/Eisbock-stacked.jpg

 

Bill

 

 

 

0 Kudos
Reply

2,411 Views
BSN
Contributor I

Very nice website...!

 

Eduardo

0 Kudos
Reply

2,413 Views
BSN
Contributor I

As a fast solution for this, just changing the order of things in port.c timer 1 interuption can solve the problem:

 

 Change from this:

 

interrupt VectorNumber_Vtpm1ch0   vTimerISR( void )
{     
    asm( MOVEM.L (A7),D0-D2/A0-A1);            // dummy restore
   asm( LEA 20(A7),A7 );
   asm( UNLK A6);
 

     TPM1C0V += cThisTimerInc;
     TPM1C0SC &= (~0x80);                        /* Reset interrupt request flag */
  ...

 

 

To this:

 

interrupt VectorNumber_Vtpm1ch0   vTimerISR( void )
{

 

  

     TPM1C0V += cThisTimerInc;
     TPM1C0SC &= (~0x80);                        /* Reset interrupt request flag */

 

  asm( MOVEM.L (A7),D0-D2/A0-A1);            // dummy restore
   asm( LEA 20(A7),A7 );
   asm( UNLK A6);
 
  ...

}

 

 

That will do it.

Don't forget to take a look at your memcpy (in queue.c) if you are going to use Codewarrior 6.2 and  be careful with those hardware.c functions.

 

Eduardo

 

 

 

 

0 Kudos
Reply