after reading the first byte of the integer value. The interrupt will occur before or after reading the value, but never e.g. It means, it is not possible to process an interrupt in the middle of reading the integer. Interrupts do not need to be blocked while reading this value, because reading a single 32bit value is an atomic operation for the SAMD platform. You access the current value using the millis() function. It is marked volatile to tell the compiler, this variable can be modified from an interrupt and reads can not be optimised away. There is the variable _ulTickCount which is an unsigned 32bit integer. The following code is a summary of the relevant parts of the simpler implementation for the SAMD platform: static volatile uint32_t _ulTickCount=0 If you can find most of this code in the file wired.c ( AVR) or delay.c (SAMD). For the Arduino platform, a hardware timer is set to create an interrupt for each millisecond. These counters are usually implemented using a hardware timer and an interrupt. How is the Real-Time Counter Implemented? Therefore, even if the main code stops at one point and waits for a specific condition, the real-time counter will get increased in the “background” at the given interval. It just states the fact this counter ideally does count independently of any other parts of the firmware. What if I Need to Measure very Long Periods?Ī real-time counter is a variable or register which increases at a given time interval.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |