![]() ![]() Special design is necessary to share data between interrupt code and the rest of your program. This important feature is absolutely necessary for mission-critical tasks. Therefore, their executions are not blocked by bad-behaving functions / tasks. The most important feature is they're ISR-based timers The accuracy is nearly perfect compared to software timers. ![]() Unsigned long miliseconds), you just consume only one NRF52 timer and avoid conflicting with other cores' tasks. Now even you use all these new 16 ISR-based timers,with their maximum interval practically unlimited (limited only by I tried the interrupt thing and here is what I got. My gut feeling is that the repeatability of the ISR depends on what the IRQ is interrupting. Serial.println( String(count) + String(", ") + String(diffCount) ) The time is usually 99.6us but sometimes I see a time as short as 82us and as long as 104us. The time from the leading edge to leading edge is the time from ISR to ISR. In the ISR I turned an LED on and then off. To minimize processor loading I removed all serial stuff. I am trying to learn mdeb and interrupts. You might have to change the ADC settings to get the sampling rate high enough if you use this to read analog values. Remember to keep the called function minimal since it is run in the interrupt-context.ītw. Which is pretty close to the expected value of 10000 function calls per second considering that we are using delay() and Serial.print() for debugging. This is quite simple and mostly handles same role as classic Arduino micros-function.īetter way is to use the Ticker-class to call a function periodically through an interrupt.Įxample of calling a function every 100us: #include ĬounterTicker.attach_us( ISRcounter, 100 ) // Call ISRcounter function every 100 us.ĭiffCount = count - lastCount // Count how many times ISRcounter was called. There is a precise clock/timer implemented in the MBED-OS through the HighResClock-class which offers precision to at least microseconds. ![]() NRF_PPI->CHENSET = ( 1UL << PPI_CHANNEL_T4 ) NRF_PPI->CH.TEP = ( uint32_t )&NRF_GPIOTE->TASKS_OUT NRF_PPI->CH.EEP = ( uint32_t )&NRF_TIMER4->EVENTS_COMPARE NRF_GPIOTE->CONFIG = ( GPIOTE_CONFIG_MODE_Task EVENTS_COMPARE and GPIOTE->TASKS_OUT NRF_TIMER4->CC = 16000000 / SAMPLES_PER_SECOND // Needs prescaler set to 0 (1:1) 16MHz clock NRF_TIMER4->SHORTS = TIMER_SHORTS_COMPARE0_CLEAR_Enabled PRESCALER = 0 NRF_TIMER4->BITMODE = TIMER_BITMODE_BITMODE_16Bit NRF_TIMER4->MODE = TIMER_MODE_MODE_Timer In my example in this article, the function to be interrupted will be passed in as a parameter #define SAMPLES_PER_SECOND (2000000) I have seen similar codes with Timer4 settingsīut I don't know how he calls PPI to work This is related to the accuracy of the sampled data What I need is a "fixed cycle" to read the data ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |