Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4151

General • Re: USB poll?

$
0
0
Was the PWM hardware supposed to be capable of doing this? Is DMA this fast? (3.2Gbps!!!)

Polling example using time_us_64(): (Should be adaptable using systick)

Code:

static volatile uint64_t last_time;static volatile uint64_t difference;static volatile bool isValid;// Note: This belongs in RAM//may require core's bus access to be promotedvoid isr() {difference = time_us_64() - last_time;isValid = true;// TODO: Clear interrupt}void operation() {constexpr uint64_t isr_time_us = 0;// TODO: Setup//make sure the ISR is set to a low number in priority (ARM did this backwards stuff.)isValid = false;last_time = time_us_64() + isr_time_us;// TODO: Enable process driving ISR// Note: This can create jitter //unless in warm XIP cache without contention//unless in reserved blocking RAM without strippingwhile(!isValid) {tight_loop_contents();}}

If I was to disable the interrupt controller in the middle of a low priority interrupt. Then I have created a window for priority inversion where a high priority interrupt cannot proceed. This is basically a deadlock zone and represents silly design for priority sensitive operations. Only certain parts of code should ever be this critical and by default carry the highest priority. (Don't lie to yourself.)

Some OS do this behind your back. Lot of these are deferred systems by design. Play by the rules of the scheduler and all is well. nS is too precise for OS user code without help.

Statistics: Posted by dthacher — Sun Jun 09, 2024 9:23 am



Viewing all articles
Browse latest Browse all 4151

Trending Articles