does anyone have freeRTOS running on this MCU… It is extremely similar to the ATmega328 witht the nasty exception of always being delivered with the WOTON fuse unset… cannot use watchdog interrupts.
I use freeRTOS on all my projects of any size and love it… I also love the added feature of the LGT MCU but have not been able to use it… I don’t have enough programming experience to do a port… In my limited thinking it should just be a matter of changing the tick interrupt to a different timer… I actually tried it but tasks would not switch…
Which timers are available on the part? You need to select one that can generate a tick at the frequency you require, then install the FreeRTOS tick handler on that instead of which ever timer is used in the example. The way you write and install the tick interrupt should be identical no matter which timer is used - the only difference will be how you clear the timer - for that reason my first suggestion would be to just get a timer interrupt executing at the frequency you require outside of any FreeRTOS application (just set it up from main()) as a first step, and only then add in the FreeRTOS code.
If the variable is declared in the function as you have done, it is not kept between calls to the function. You can either make if a file global variable (perhaps static so other files can’t access it) or you can make it a function static variable, so it keeps its value between function invocations. The variable, since only accessed inside one interrupt, doesn’t need to be volatile.
You could use either of the variables for your scaler. The =0 s aren’t strictly needed as they will be automatically zeroed on program start, but I prefer to make them explicit. Note that the function static initialization only happens at program start or the first run of the function, not every invocation.
Hi CanHobby,
May I ask whether you have any progress in this one? I got LGT8F328P and tried a port to this MCU from a ported version of Atmega128 but no lucks, the task doesn’t switch. I’m not sure what wrong with the port, it’s using Timer1 COMPA to tick. I want to use the LGT8F328P for some projects with FreeRTOS.