Hello there, i did an arduino program with the chibios library.
I create 2 theade the first thread is high priority+1
static THD_FUNCTION(Thread1, arg) {
while (1) {
while (1) {
my_function();
chThdSleepMicroseconds(10);
}
}
the Second thread high priority-1
static THD_FUNCTION(Thread2, arg) {
while (1) {
Serial.print(result);
chThdSleepMicroseconds(1);
}}
My problem is that i'm not sure that my first thread start every 10 MS
sconde problem, i want the first thread start one time every 10 MS is there other function without chThdSleepMicroseconds();
thanks
Time problem
-
- Posts: 359
- Joined: Sat Jan 07, 2012 6:22 pm
- Location: Brazil
- Has thanked: 1 time
- Been thanked: 20 times
- Contact:
Re: Time problem
It should be chThdSleepMilliseconds instead of chThdSleepMicroseconds! Also in your first thread, having two nested infinite loops:
doesn't seem very useful...
Fabio Utzig
Code: Select all
while (1) {
while (1) {
...
}
}
doesn't seem very useful...
Fabio Utzig
- 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: Time problem
Also note that times are rounded up to the clock tick period, if your system tick is 100Hz then the resolution is 1/100 of second.
Giovanni
Giovanni
Re: Time problem
Hello, thanks for your answer.
@utzig yes i did milisecond and just one while(1), i typed wrong message ^^.
@GiovanniBut how do i know the resolution of my system ??
i have arduino uno. could you tell me what's the resolution please
and could you explain me "times are rounded up to the clock tick period" i am fan of CHIBIOS i love this RTOS
Thanks
@utzig yes i did milisecond and just one while(1), i typed wrong message ^^.
@GiovanniBut how do i know the resolution of my system ??
i have arduino uno. could you tell me what's the resolution please
and could you explain me "times are rounded up to the clock tick period" i am fan of CHIBIOS i love this RTOS
Thanks
-
- Posts: 359
- Joined: Sat Jan 07, 2012 6:22 pm
- Location: Brazil
- Has thanked: 1 time
- Been thanked: 20 times
- Contact:
Re: Time problem
If your crystal is 16MHz and you're using the library from this repo https://github.com/greiman/ChibiOS-Arduino, your tick will be 1/976 which is around 1ms. The minimum sleep time is than 1ms. More info on this thread: viewtopic.php?f=21&t=2647
Re: Time problem
The poste that you gave me. i read that some one modify the value CH_TIME_QUANTUM.
what ever, i have a question. for exemple i have a function in my thread, i want my function doesn't exceed 10 Ms. or i want my function execute every 10MS. how do i program that ?
Thanks
what ever, i have a question. for exemple i have a function in my thread, i want my function doesn't exceed 10 Ms. or i want my function execute every 10MS. how do i program that ?
Thanks
- 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: Time problem
Thanks for the replay, but what is the difference between this
and this
and i have a difficulte to understand the the system tick period ?? could you explain me what is it please
Code: Select all
msg_t my_thread(void *param) {
systime_t time = chTimeNow(); // T0
while (true) {
time += MS2ST(1000); // Next deadline
do_something();
chThdSleepUntil(time);
}
}
and this
Code: Select all
static THD_FUNCTION(Thread1, arg) {
systime_t time = chTimeNow(); // T0
while (true) {
time += MS2ST(1000); // Next deadline
do_something();
chThdSleepUntil(time);
}
}
and i have a difficulte to understand the the system tick period ?? could you explain me what is it please
Who is online
Users browsing this forum: No registered users and 21 guests