-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CCmicros - micros version using Cycle counter #330
Conversation
Alternate micros() extends millis() using ARM_DWT_CYCCNT > Also makes unused_interrupt_vector() weak to allow user override like Teensy3
Replace micros for one using CycCnt
This saves a cycle - and checks both values to avoid _isr change of either value based on code/execution
Paul - is this complete - all based only on F_CPU_ACTUAL? Is that always right? Is there any needed _isr related cache issues that need checked? |
I have many concerns about ways this could fail.... |
Any specifics or directions? The startup is odd with the change and the MAGIC_val I was testing then brought in fetched cores and it went odd - and the magic was not needed before ... I'll go edit PR and perhaps you could do a pull for micros unchanged and a rename of the new code ccmicros() for testing and observation |
micros() unchanged - minor systick_isr() diversion - one line added to systick_isr.
Put pull request edit to have ccmicros() as the new CycCnt code. Used like that while I was testing against micros(). Will use the manitou's GPT1_CNT code to compare. I'll see if I can use the exposed: And add my debug_t4 trace logging version of debug_t3 I started on to give more info on faults and without. on beta thread at post 960 - https://forum.pjrc.com/threads/54711-Teensy-4-0-First-Beta-Test?p=195856&viewfull=1#post195856 |
Is this better:: testing and wrote this in post 973: Avoids a recurring division in systick_isr . And micros() will always track millis() [no need for _sync code _isr swap]- tracking includes its jitter on handling the _isr and jumps for lost counts. But for 1 MHz timing with 600 MHz CycCnt the jitter should go away in rounding error |
Just posted: https://forum.pjrc.com/threads/54711-Teensy-4-0-First-Beta-Test?p=196050&viewfull=1#post196050 Have a good test sketch posted that uses 'ARM Synchronization Primitives ' for reading the values from the _isr. I'll update the Pull request in some hours with offered code based on that - and any feedback. |
for micros() Use: ARM Synchronization Primitives, include of arm_math.h Get systick_isr data safely without disable interrupts, uses systick_safe_read as indicator variable
Code update includes ARM Synchronization Primitives __LDREXW and __STREXW to wrap the read of TWO systick values and force read reading if systick_isr [or any] interrupt occurs. Tested with notes forum post 1029 : https://forum.pjrc.com/threads/54711-Teensy-4-0-First-Beta-Test?p=196115&viewfull=1#post196115 and links github to sample sketches 'stand alone' w/Syncron_isr and using updated micros Syncron_Micros. |
Done! - Thanks Frank - good to know you looked that closely! I intended to remove that 'volatile' when I pulled out my other variant that relied on it. |
ok, let's give this a try and see how it goes.... |
Nice. Fetched the CORES - put on my install and my test code is working with no build issues. |
Alternate micros() extends millis() using ARM_DWT_CYCCNT
Also makes unused_interrupt_vector() weak to allow user override like Teensy3
Startup is CycCnt dependent to match millis() in significant digits - but once running offset to last systick_isr is true based on Cycle Counter