Question to Giovanni

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
RTOSman
Posts: 29
Joined: Mon Feb 01, 2016 6:11 pm

Question to Giovanni

Postby RTOSman » Tue Feb 16, 2016 7:55 pm

Hello Mr Giovanni. i use chibios librrary for arduino and i find it powerful i tried many application on arduino uno board. but arduino board has not a real time clock. the timer of arduino it's not really accurate, so i want to use RTC DS3231. my question is how to make the function chThdSleepMilliseconds or ThreadSleepMicroseconds work with RTC DS3231
Please answer :)

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Question to Giovanni

Postby Giovanni » Tue Feb 16, 2016 8:22 pm

The OS does not need necessarily an RTC, it just need a periodic interrupt, any periodic interrupt source can be used.

Giovanni

RTOSman
Posts: 29
Joined: Mon Feb 01, 2016 6:11 pm

Re: Question to Giovanni

Postby RTOSman » Tue Feb 16, 2016 8:34 pm

The problem is the chVTGetSystemTimeX() not accurate on the arduini uno. i did this code

Code: Select all

while (1)
   {
   start += 10;
   Serial.println(chVTGetSystemTimeX()/1000);
   }


i compare the values of chVTGetSystemTimeX()/1000) with my stopwatch of my phone. after 3 minutes the values of chVTGetSystemTimeX()/1000) not same with the values of my stop watch. 400 seconds from chVTGetSystemTimeX() and 399 from the stopwatch. and overt the time i had 500 497.

i did som modificaion to get 1000 ticks = 1000 ms in board.c

Code: Select all

#include "ch.h"
#include "hal.h"
CH_IRQ_HANDLER(TIMER0_COMPA_vect) {
  CH_IRQ_PROLOGUE();
  OCR0A += 250; // ****** ADD THIS LINE FOR 1.000 MS TICK************
  chSysLockFromISR();
  chSysTimerHandlerI();
  chSysUnlockFromISR();
  CH_IRQ_EPILOGUE();
}
/*
 * Board-specific initialization code.
 */
void boardInit(void) {
  /*
   * Timer 0 setup.
   */
  OCR0A = 128;
  TIMSK0  |= (1 << OCIE0A);                               /* IRQ on compare.  */
  TCCR0A &= ~((1 << WGM00) | (1 << WGM01)); // ****** ADD THIS LINE FOR 1.000 MS TICK************
}


and i change this
#define CH_CFG_ST_FREQUENCY 1000 // WHG.


so please MR Giovanni, how do i to get exactly the real time please. i use arduino uno.
find me a solution :(

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Question to Giovanni

Postby Giovanni » Tue Feb 16, 2016 8:37 pm

Just set CH_CFG_ST_FREQUENCY to the exact timer frequency and you will have the best approximation. Alternatively provide a system tick from some external timer to an interrupt pin.

Giovanni

RTOSman
Posts: 29
Joined: Mon Feb 01, 2016 6:11 pm

Re: Question to Giovanni

Postby RTOSman » Tue Feb 16, 2016 8:53 pm

how do i know the exact timer frequency value of CH_CFG_ST_FREQUENCY.
i have arduino uno
please

RTOSman
Posts: 29
Joined: Mon Feb 01, 2016 6:11 pm

Re: Question to Giovanni

Postby RTOSman » Tue Feb 16, 2016 9:28 pm

Giovanni you didn't answer me !!!

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Question to Giovanni

Postby Giovanni » Tue Feb 16, 2016 9:55 pm

You should not expect answers in real time...

I don't have Arduino one and cannot provide specific support, what I can do is to give generic advice. Studying documentation about your platform is up to you.

Giovanni

RTOSman
Posts: 29
Joined: Mon Feb 01, 2016 6:11 pm

Re: Question to Giovanni

Postby RTOSman » Tue Feb 16, 2016 10:14 pm

but you did a library for arduino !!!!

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Question to Giovanni

Postby Giovanni » Tue Feb 16, 2016 10:26 pm


RTOSman
Posts: 29
Joined: Mon Feb 01, 2016 6:11 pm

Re: Question to Giovanni

Postby RTOSman » Tue Feb 16, 2016 11:09 pm

Yes this library


Return to “Development and Feedback”

Who is online

Users browsing this forum: No registered users and 53 guests