![]() Is there an actual example in the code that is being blamed on this? The proper thing to do in this case is to cli() your time sensitive section of code sei() My guess is that the cli here is causing troubles with some other code that you wrote and is causing jitter. If you want to make it still safe without globally disabling ISRs then use a semaphore, or other lock, and spin until free to go on. but the first task hasnt finished, when the multi task returns to it, its data would/could/will be corrupted ( ie. Imagine you had two tasks running, and they are switched by lets say timer 2, between turning off and back on, if the second task completes before its turned the overflow enable ISR back on. You should take a copy, clear the Timer 0 overflow enabled flag ( if needed ), and then afterwards restore the copy to remain multi tasking friendly. Unfortunately, your patch also makes it not safe to call if you are multitasking.ĭue to you blindly switching the interrupt flag back on. Return ((m << 8) + t) * (64 / clockCyclesPerMicrosecond()) TIMSK0 |= 1 TIMSK0 &= ~(1 in the middle of a write to timer0_millis) disable interrupts while we read timer0_millis or we might get an Since the objective is to disable timer0 interrupt on overflow, i highly recomend to change code so that only this specific interrupt is disabled.ĭoing the way i show bellow also frees 1byte of program code per function changed : The global interrupt disable in millis() and micros() functions (also on digitalWrite() and pinMode()) on arduino core library causes erratic occurrence of other interrupts that really dont impact the primary reason it's disabled in this functions.ĭisabling global interrupts can lead to delaying some important interrupts (other timers, pins, adc, etc) used by other libs or part of the code. It's very bad for timed interrupt sensitive designs. ![]() In wiring lib, usualy a global interrupt disabled is issued when not realy needed.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |