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
Question to Giovanni
- 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
The OS does not need necessarily an RTC, it just need a periodic interrupt, any periodic interrupt source can be used.
Giovanni
Giovanni
Re: Question to Giovanni
The problem is the chVTGetSystemTimeX() not accurate on the arduini uno. i did this code
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
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
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
- 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
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
Giovanni
Re: Question to Giovanni
how do i know the exact timer frequency value of CH_CFG_ST_FREQUENCY.
i have arduino uno
please
i have arduino uno
please
- 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
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
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
- 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
You mean this library?
https://github.com/greiman/ChibiOS-Arduino
http://jeelabs.org/2013/05/25/chibios-f ... ino-ide-2/
Try Google: https://www.google.com/search?q=chibios+arduino
I never used an Arduino personally.
Giovanni
https://github.com/greiman/ChibiOS-Arduino
http://jeelabs.org/2013/05/25/chibios-f ... ino-ide-2/
Try Google: https://www.google.com/search?q=chibios+arduino
I never used an Arduino personally.
Giovanni
Return to “Development and Feedback”
Who is online
Users browsing this forum: No registered users and 53 guests