Skip to content
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

Timer-Queue does not seem to execute tasks when debugger is not attached #123

Closed
jamesmunns opened this issue Dec 28, 2018 · 9 comments
Closed

Comments

@jamesmunns
Copy link

I have some examples which do the following:

  • Toggle one LED periodically, based on TimerQueue Intervals - code here
  • Toggle another LED when a button is pressed, driven by interrupts - code here

When the debugger IS attached, both of these features work correctly. When a debugger is NOT attached, only the interrupt driven task functions correctly. I suspect that without the debugger attached, certain trace functionality is not available, preventing the timer from firing correctly. I saw some discussion of this on stack overflow, which might be interesting.

This is likely to be resolved when #115 lands.

@TeXitoi
Copy link
Collaborator

TeXitoi commented Dec 28, 2018

Looks similar to rust-embedded/cortex-m#111

@TeXitoi
Copy link
Collaborator

TeXitoi commented Dec 28, 2018

Seems to be already called in RTFM, but not the access magic described on the stack overflow thread.

@jamesmunns
Copy link
Author

Possibly relevant (in case different vendors implement this functionality in different ways) - the specific chip in question here is the Nordic nRF52832, an thumbv7em-none-eabihf target

@eupn
Copy link

eupn commented Feb 1, 2019

Confirm, on my nRF52-DK (PCA10040) RTFM-based blinky example doesn't work without debugger attached.

EDIT:

It seems that either DWT cycle counter or SYST is disabled (stops counting) or can't be retained in low power mode, but preserved when debugger is attached. nRF52 chips are entering this mode after WFI instruction being asserted in #[idle] handler. Removing this instruction call from said handler fixes the issue.

This is actually rendering RTFM timer queue (as it implemented for now) useless for low-power applications. Have to patiently wait for #115 to land.

@japaric
Copy link
Collaborator

japaric commented Feb 8, 2019

It seems that either DWT cycle counter or SYST is disabled

AFAIS in stm32 land, these are behind device specific debug settings. stm32 uses, for example, the DBG / DBGMCU peripheral to set these settings. We can't do device specific stuff within rtfm so we can't fix this in rtfm. If you change the debug settings (if possible at all) in init then the timer queue will work.

@perlindgren
Copy link
Collaborator

perlindgren commented Feb 8, 2019 via email

@japaric
Copy link
Collaborator

japaric commented May 1, 2019

People observing the timer queue not working / the DWT CYCCNT register not increasing: please try PR #185 or #186 and report back if that fixes this issue for you.

@japaric
Copy link
Collaborator

japaric commented May 2, 2019

People observing the timer queue not working / the DWT CYCCNT register not increasing

I checked a nRF52840 and the "software lock" feature doesn't seem to be implemented for the DWT (register DWT_LSR reads as zero) -- the CYCCNT increases as expected -- so those PRs will likely not help for that chip. Perhaps there's some device / nRF specific lock that keeps the DWT disabled on reset (its clock could be disabled on reset to save power?).

@korken89
Copy link
Collaborator

In v5 it is up to the user to initialize the monotonic timer.

andrewgazelka pushed a commit to andrewgazelka/cortex-m-rtic that referenced this issue Nov 3, 2021
123: respect declared unsafety r=therealprof a=japaric

the `#[entry]` and `#[exception]` attributes ignored the declared unsafety and
always expanded to a safe function. This caused the following valid code to
error at compile time:

``` rust
 #[entry]
unsafe fn main() -> ! {
    foo();
    //~^ ERROR call to unsafe function is unsafe and requires unsafe function or block

    loop {}
}

unsafe fn foo() {}
```

r? @rust-embedded/cortex-m (anyone)

Co-authored-by: Jorge Aparicio <jorge@japaric.io>
andrewgazelka pushed a commit to andrewgazelka/cortex-m-rtic that referenced this issue Nov 3, 2021
this is a backport of PR rtic-rs#123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants