-
Notifications
You must be signed in to change notification settings - Fork 2k
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
cpu/cc2538: timer broken? #6419
Comments
Please look into the timer_init() function to see in what cases it might fail. |
Related to #6392 (comment) ? |
Yes I noticed that yesterday and it's about the initialisation first, then the conversions used by xtimer... |
@kYc0o you knowthe fix out of the box? Otherwise I will (must) go into details soon |
Concerning the |
I was working on the fix yesterday but didn't finish. I'm still trying today but I'm busy with waspmote's timers... if you're already there I'll let you solve the bug I'd you find out what it is. |
The timer should be initialised at 16MHz according to XTIMER_HZ. |
I'm changing job/country now so probably I won't have time to look this anytime soon, but @PeterKietzmann is right-on spot as the expected frequency is different |
I have a strong assumption that this configuration is incorrect.
@gebart, @kaspar030 I'm pretty inexperienced and uninformed about the |
PS: Applying proposal of #6427 does not solve the issue |
@kYc0o IMO this issue has high priority. Recently it seemed you're into this. Any chance for a fix from you side? |
I'm investigating this and the waspmote, I'll try to provide a fix this week |
I still didn't fully understand where you see the relation between these two, but I trust you :-)! Looking forward for that! |
It's just that both are getting bad initialisation prescalers... but the fixes will be different indeed. |
Well after a deep investigation the culprit is #5608 , specifically 63e9115 . I'm looking deeper so if someone can helps it would be faster maybe. The insights are:
As for the periph_timer test, it needs to be reworked since it doesn't allow to dynamically set the timer initialisation frequency, which is different for the timers on cc2538 cpus. |
* the remote boards (in remote-common) initialise the timer at a very
high frequency of 16MHz, for a 16bit timer, which could overload the
xtimer layer. Changing the frequency doesn't help.
Like, setting the frequency to 1MHz or even 250KHz via prescaler doesn't
help?
* The tick conversions shift a lot while using the default 16MHz (4
shifts are needed) so this can also maybe break something.
Yep, 16MHz on a 16bit timer with 16MHz CPU clock is probably pushing it
too much...
|
Yes, I tried several frequencies and the timer gets stuck, it's like if the overflow interrupt is not working. |
I'm also trying to investigate this topic. I made a remarkable discovery that tests/xtimer_usleep is running to the end, when I connected with the jlink adapter via JTAG. |
I've also had issues with my applications getting stuck at I've determined that when My current workaround is to start a new thread and only call the sensor's read routine from within that thread. Has anyone found anything about what's causing this? |
@drcef Can you test your code without the workaround with the previous RIOT release? There are several modifications done for the current release that could have broken xtimer, but I cannot determine exactly which one. |
I ran several tests but no solution to this so far. First, I thought that the 16Bit (vs. default 32Bit) timer might be a problem, but then I tested with an atmega328p Arduino (16Bit timer, too) and everything works. I created a gist with the outputs for boards remote-revb and arduino-duemilanove for |
@smlng I spend quite longtime analysing on which way #5608 would introduce this problem, however I couldn't see anything harming the behaviour specifically for this platform. I also tried 16 and 32 bits timers with xtimer, and I have always the same behaviour. My findings so far lead me to suspect that for some reason the interrupt is not being triggered, causing the timer being stuck somehow, then xtimer cannot catch the interrupt with its callback function. However, looking at your gist, it seems that for your example the callback is actually triggered, so I can't see where it gets stuck. Can you explain a bit more how did you test it? |
@kYc0o I tested with |
I tested with
Basically the in the output from
|
@PeterKietzmann #6685 fixes the weird output in |
On remote boards it appears that
xtimer_usleep
hangs. Didn't test on other cc2538 boards. Even tests/periph_timer acts weird as it can't initialise all timers:The text was updated successfully, but these errors were encountered: