DuinOS: small and simple rtos

I can tell you it is a RAM issue causing the ATmega168 not to be able to use serial output. As a test, changing configTOTAL_HEAP_SIZE in FreeRTOSConfig.h to 500 allowed it to work.

Good! So I think it must be the default heap size when using the 168. Annotated for the v0.2 version too.

Hi Julian,
found the taskENTER_CRITICAL/portENTER_CRITICAL and the exit macros grepping through the source but unclear about how to include into my test program.
A simple #include <DuinOS/task.h> doesnt seem to be found..

unsure of the correct path here(I am on OSX)

gwen

You just need #include "DuinOS.h", that header will include task.h. I'm also on OS X.

Hi, the sintax is:

taskENTER_CRITICAL();
...
taskEXIT_CRITICAL();

It must work without including nothing in the main program, but in the libraries, you may need to include "DuinOS.h", as Chumbud said.

Good! So I think it must be the default heap size when using the 168. Annotated for the v0.2 version too.

I checked the ELF file and with the 800 bytes allocated to the configTOTAL_HEAP_SIZE for the ATmega 168, the program listing above is using 1125 bytes of static RAM ::). The MoreComplexBlinking example with configTOTAL_HEAP_SIZE still set to 800 bytes only uses 833 bytes of RAM.

Hi Julian,
I tried.. but no success(prolly because of my ineptitude in the arduino environment) so for now will simply dedicate a 328p as an I2c Slave(without DuinOS) to interrogate my onewire temp sensors and pwm interfaced Co2(which can speak I2C also) sensor and yes mostly likely the HS1101 humidity sensor as I depend on an rctime emulation for reading.

Then I will simply convey the results via I2C on the sanguino running DuinOS as I2C works just fine(duinos currently using I2C to read the 1307 RTC) (fortunately I have a few arduino capable boards in my junkbox).

As I will get home over a local holiday this week I might be able to find some DS18S20(not too accurate but speaks one wire just fine) and mail 2 or 3 out to you(they are kind of small) and see if you can make anymore progress than I have(if you are interested)?

gwen

Hi gwen, many thanks for your offer. I can say the following: Please don't send me the DS18S20, because they will not pass the Argentine Custom. I can get them here (just don't have them now). Regarding the OneWire, we will return to the whole project in about 2-3 weeks (I hope), because now are trying to get our robots ready. Then, when working again in DuinOS, the OneWire will be one of the issues, because that library is not working at all. Any comment/suggestions to this little "roadmap" are welcome.

Regards,
Julián

Questions about the ATmega328P

Which IO pins do I need to avoid because they are used by DuinOS/Freertos?

Hi, the OS does not use IO pins, but because it uses the Timer 1, there is no PWM (writeAnalog function) on pins 9 and 10 (unless you do the PWM by software).

Regards,
Julián

Note that the arduino servo library requires timer1 so that library cannot be used with the OS. However it should be possible for someone to adapt the code so that servicing the servo channels can be done as a task. I don't have the time to do this myself but would be happy to assist if someone wanted to take this on

I think it will be one of the priorities for the v0.2. The servos are very important. We are thinking in re-implement a timer ISR to behave as the real time "master", with a higher ISR priority than the task switch ISR (timer 1). So, in this "RT" ISR it may be possible to put all the servos, soft pwm/freq, onewire/delaymicroseconds stuff. What do you think?

are you considering using nested interrupts and does the OS currently support this? I was wondering how long a task switch takes and if interrupts disabled during the switch.

Hi, here you will find some info about that:

http://www.freertos.org/PC/

(in the left menu go to Results->AVR/WinAVR->Results).

Regards,
Julián

thanks Julián, but it looks like those tests are comparative performance results on different platforms but do not directly indicate the time to do a single task switch (unless I missed something). Are there any results of tests with a scope or logic analyzer to specifically measure the task switching overhead?

Hi, I believe there are the values you are asking for. The page does not let me to copy the exactly link, so I'm quoting here the results from http://www.freertos.org/PC:

Scheduler tick function: 41.8[ch956]s, (56.2[ch956]s), [52.8[ch956]s].

with an ATMega323 @ 8 MHz and compiled with an old 2003 WinAVR.

I'm running tests with a digital osciloscope, but will publish when they are finished (because I ask to the FreeRTOS people to do so, due to the original license specific clause about publishing benchmarks).

Regards,
Julián

Hi Julian,

do you have a bugtracker setup for DuinOS yet?
So we can track issues with various support libs that will need refactoring(fixing) to work with DuinOS.

gwen

It may also be nice if a list/wiki were setup to indicate compatible libraries.

hey chumbud,
I found I was able to get I2C writes working fairly reliably but my results with i2c reads are all over the map.. sometimes my rtc1307 code works sometimes it doesnt(currently doesnt and I didnt svn the sketch that had it working momentarily..(does arduino gui even support this?))
typically now its failing on the second read sequence.

so i2c reads should be added to the noncompatible list.. ie its a big one on the second i2c read the rtos dies(or so it seems as non of my canary tasks are making any noise/updates anymore).

yes would be nice to have wiki and a bugtracker.

gwen
ps we could just add a wiki section onto the arduino playground at Arduino Playground - GeneralCodeLibrary and probably should create a DuinOS Section to that wiki.. just found out my admittedly limited login privs dont allow me to edit the code snippets section.Can one of the admins take care of this? or grant me the necessary privs.

Have you tried to run Duinos with the WiShield yet?
There is a conflict with pin 10 and maybe more than that.

I understand from the first post that Duinos/freertos uses timer 1 which has something to do with digital pins 9 and 10. Does it need any other pins or interrupts to operate?

The WiShield uses the SPI system and pin 10 is used for slave select. I don't know if it goes deeper than that. WiShield can use either digital pin 2 or 8 for an interrupt pin. SO it needs digital pins 2,10,11,12,13 or 8,10,11,12,13.

Do you know of any other conficts that I should be looking for?

Jim