Jump to content


Photo

Migrating Demo To Novo Rtos


7 replies to this topic

#1 JorgeF

JorgeF

    Super Enthusiast

  • EstablishedMember
  • PipPipPip
  • 205 posts

Posted 16 February 2012 - 01:31 AM

Hi Folks

I bought a BoostC 7 Pro licence a few months ago, and finally got the time to get aquainted with it.
After one week and some 8 working programs I decided its time to start messing around with the NOVO RTOS.
With your help (in this forum) I already managed to put 5 or 6 NOVO test programs to work. There were very simple programs playing with some LEDs and an ADC.
By the way, my test hardware is the Microchip Pickit 28 pin demo board fitted with a PIC16F886 mcu that come with my PicKit Serial Analyzer.
The next step in my "self-teaching" is a more complex project.
I'm in the process of migrating to NOVO the demo program that Microchip fitted to the above mentioned demo board (original in ASM)..


Now that I put you all in context, the questions:

This demo program has a power on sequence that flashes the 4 leds in several ways before entering normal operation.

I'm facing several options to implement this:

a- Execute this startup sequence before starting the NOVO kernel
I would have to use normal BoostC delays as Sys_Sleep() won't be available.
b- Create a standard task that runs only once and then waits forever on a semaphore that nobody signals.
c- Only Start this led show off task and use a semaphore at the end to tell the main() function to Stop it and Start all the others.

While looking at these and other more twisted options, some doubts about NOVO aroused.

1) Can a task stop himself? Is it "legal" to call Sys_StopTask from within the task beeing stopped?
2) If I use priorities, what is the priority of the idle task?
3) By the way is it correct to call "Idle Task" to the "while(1){Sys_Yield();}" loop in the "main()" function? Or there is some "Idle Task" hidden inside the NOVO kernel?

Its not my first experience with multi-tasking kernels, either cooperative or preemptive. But its a first time on such small devices. Anyway each kernel as its own semanthics so I'd better start from the begining.


Any toughts or advice would be very appreciated.


Best regards

Jorge

PS: So far I'm really liking BoostC and NOVO, they look like great tools. Congrats to the SourceBoost team. :)

Edited by JorgeF, 16 February 2012 - 09:27 AM.


#2 Dave

Dave

    Super Maniac

  • Administrators
  • PipPipPipPipPip
  • 2,088 posts
  • Gender:Male
  • Location:UK
  • Interests:How things work, Electronics, Software, Cycling.

Posted 16 February 2012 - 08:29 PM

1) Can a task stop himself? Is it "legal" to call Sys_StopTask from within the task beeing stopped?

Yes, is is a valid to do this.

2) If I use priorities, what is the priority of the idle task?

The idle task is returned to every time the scheduler head is reached. The highest priority tasks are executed one at a time until they have all yielded, then there is one execution of the idle task before returning to the task queue. The idle task really sits at the head of the queue, so has the same priority as the highest priority task in the queue.

3) By the way is it correct to call "Idle Task" to the "while(1){Sys_Yield();}" loop in the "main()" function? Or there is some "Idle Task" hidden inside the NOVO kernel?

Yes this is the idle task, called every time the scheduler task queue head is return to.

I hope that helps.

Best way to implement you code is probably the simplest.
No point in using tasks unless you want to do more than one thing at a time.

Regards
Dave

#3 JorgeF

JorgeF

    Super Enthusiast

  • EstablishedMember
  • PipPipPip
  • 205 posts

Posted 17 February 2012 - 10:44 PM

Hi Folks

Correction
Fisrst of all, thank you Pavel for your repply to my previous questions.
First of all, thank you Dave for your repply to my previous questions.


Now, a new one :)


In an example in the NOVO manual, I found the following:
...
InitTimer();
SysInit();
.....

The InitTimer() function enables the overflow interrupt for TIMER0, and the interrupt handler calls SysTimerUpdate().
Wouldn't it be safer to only enable the interrupts after calling SysInit() ?


Best regards

Jorge

Edited by JorgeF, 18 February 2012 - 03:08 PM.


#4 Dave

Dave

    Super Maniac

  • Administrators
  • PipPipPipPipPip
  • 2,088 posts
  • Gender:Male
  • Location:UK
  • Interests:How things work, Electronics, Software, Cycling.

Posted 18 February 2012 - 01:37 PM

JorgeF,

Fisrst of all, thank you Pavel for your repply to my previous questions.

Was it him that replied ??

In an example in the NOVO manual, I found the following:
...
InitTimer();
SysInit();
.....

The InitTimer() function enables the overflow interrupt for TIMER0, and the interrupt handler calls SysTimerUpdate().
Wouldn't it be safer to only enable the interrupts after calling SysInit() ?

You are indeed correct, the example SysInit() should really be called first.

The example only manages to work reliably by the fact that by the time SysTimerUpdate() is called enough time has passed to do the initialisation.
The example needs to be corrected.

Regards
Dave

#5 JorgeF

JorgeF

    Super Enthusiast

  • EstablishedMember
  • PipPipPip
  • 205 posts

Posted 18 February 2012 - 03:22 PM

JorgeF,


Fisrst of all, thank you Pavel for your repply to my previous questions.

Was it him that replied ??


:unsure:
Got me!
Sorry for the mess.
I posted this just after an e-mail to him.
Already corrected.


You are indeed correct, the example SysInit() should really be called first.

The example only manages to work reliably by the fact that by the time SysTimerUpdate() is called enough time has passed to do the initialisation.
The example needs to be corrected.

Regards
Dave


As I suspected.
Thank you for the quick replie.

Meanwhile, I've been digging up a little bit under de hood of NOVO, and in the generated code.
I find it funny, that your solution for the task switching mechanism (code generated by Yield()), ressembles very closely a solution that I once adopted in an ASM program where I needed to apply a priorty mechanism to several state machines as the standard "super loop" took too long.

Best regards

Jorge

#6 JorgeF

JorgeF

    Super Enthusiast

  • EstablishedMember
  • PipPipPip
  • 205 posts

Posted 29 March 2012 - 11:13 PM

Hi guys

My self-training program is finished.
I managed to set up a program in BoostC using the NOVO RTOS that mimics the sample code that Microchip fitted to the board (28 pin demo board with PIC16F886) that is part of the Pickit Serial Analyser (DV164122).

The program I made performed well with all the demos mentioned in the Pickit Serial Analyser User's guide.

It was a nice experience, the NOVO RTOS worked like a breeze and the BoostC compiler surprized me for the quality of the generated code.
I think I found a winning team.
It looks like I won't be programming in assembler again in the near future. Except, of corse, for some very critical program or some very small PIC.

Congratullations for the BoostC and NOVO team(s).


If someone as any interest on it, I'll be glad to post the full project in here.


Best regards

Jorge

Edited by JorgeF, 29 March 2012 - 11:16 PM.


#7 Pavel

Pavel

    Super Maniac

  • Administrators
  • PipPipPipPipPip
  • 1,427 posts
  • Gender:Male
  • Location:Melbourne, Australia

Posted 29 March 2012 - 11:28 PM

If someone as any interest on it, I'll be glad to post the full project in here.


Congratulations with the project. We can put the project on SourceBoost examples page on http://www.sourceboo...xampleCode.html (just mail all relevant file to support@sourceboost.com)

Regards,
Pavel

#8 JorgeF

JorgeF

    Super Enthusiast

  • EstablishedMember
  • PipPipPip
  • 205 posts

Posted 30 March 2012 - 01:58 PM

OK Pavel

But to put it available in the site, I'd better brush it a little bit.
I'll send it when ready.



Best regards

Jorge



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users