ticker / timer
- This topic has 11 replies, 3 voices, and was last updated 8 years, 5 months ago by Michael.
-
AuthorPosts
-
May 25, 2016 at 4:06 pm #12736MichaelParticipant
I’m trying to utilize a “ticker”.
Code is:#include "mbed.h" #include "mDot.h" ... Ticker toggler; DigitalOut led = PA_1; void toggle_led() {led = !led;} ... int main(){ toggler.attach(&toggle_led,0.1); ... }
But no LED blinking…
As a test, I verified I can make the LED blink:
led = 1; wait_ms(2000); led = 0; wait_ms(2000); led = 1; wait_ms(2000); led = 0; wait_ms(2000);
So, what’s wrong with the “ticker” code?
May 25, 2016 at 4:33 pm #12742Mike FioreBlockedMichael,
I’m surprised that code compiles. You’re not creating the DigitalOut object correctly. It should be
DigitalOut led(PA_1);
Cheers,
-Mike
May 25, 2016 at 5:49 pm #12744MichaelParticipantCompiles fine.
I can flash the LED “manually”.
So it works, too.
I cannot get the timer-ticker to work. That’s my problem.
-Mike
May 26, 2016 at 7:30 am #12746Mike FioreBlockedMichael,
Is your mDot in a UDK2 board? It would look like the board on this page:
http://www.multitech.com/brands/mdot-devkitIf that’s the case, PA_1 connects to the D6 LED. That line is also the RTS signal on the external serial port. The LED may not be blinking because the RTS jumper is on the board. It’s in the bank of jumpers near the power connector. You’ll need to pull the RTS jumper off before you see that LED blinking.
If you’re not using a UDK board, can you give me some more information about your setup?
Cheers,
Mike
May 26, 2016 at 9:56 am #12748MichaelParticipantHi Mike,
Thanks for the follow-up.
Yes, I’m using the UDK and have been able to flash the LED6 “manually” in the code (as mentioned previously). I chose that digital port and that LED specifically for that purpose (of flashing it). I wanted to first see if I can control the LED at all – and I can.
Then I wanted to see if I could get a “ticker” to control it. I cannot.
This is the crux of my problem. I cannot get “tickers” to “tick”.(Note: I have tried other experiments to verify the operation of the ticker that have failed – the LED is just the latest incarnation of those experiments and the easiest one to demonstrate)
b/r
MikeMay 26, 2016 at 10:14 am #12749Mike FioreBlockedMichael,
Can you post your entire main.cpp?
Also, are you building your application using the mbed online compiler? If so, can you provide the mbed, mbed-rtos, and mDot library versions you’re using?
Cheers,
Mike
May 26, 2016 at 11:00 pm #12761MichaelParticipantFirst: Yes I am using the online compiler. How do I identify the versions you request? (I’ve very recently updated these…)
Second: I worked on a simple main.cpp and I can now get the timer to fire as expected, blinking the LED. However as I add back in the rest of my code, it again fails.
History: The “rest of the code” is based in great part on the mbed library for the Sparkfun weather station for which an implementation is my ultimate goal. The ticker used in that library is meant to allow the counting of the anemometer’s rotations in one second ( counts between one second ticks ). However that tick does not appear to be firing, so I implemented a simpler ticker in my main.cpp in an effort to understand its operation better. And that tick also did not work. That is, until I deleted the original ticker in the weather code:
m_OneSecondTicker.attach_us<CAnemometer>(this, &CAnemometer::OneSecondTickerISR, 1000000);
Is there something wrong with that construct?
May 27, 2016 at 9:08 am #12768Mike FioreBlockedMichael,
In your application folder in the online compiler, you should see folders for mbed, mbed-rtos, and libmDot. If you click on each of those folders, you should see a version number in the top right window on the screen.
The fact that removing the ticker from the weather code makes everything work makes me suspect that the OneSecondTickerISR function is doing taking too long or doing something naughty. What is that ISR doing?
I’m also not sure what the
portion of that line of code is doing. It may not be the issue, I’ve just never seen that syntax before. Cheers,
Mike
May 28, 2016 at 10:00 pm #12786MichaelParticipantUnderstood. At least I have some idea *what* is in my way, if not *why* atm.
My revisions are:
libmdot: 14
mbed: 117
mbed-rtos: 121May 30, 2016 at 3:47 pm #12796Jason ReissKeymasterThere have been issues with mbed-rtos 117.
Rollback to a previous version. This should fix the join issue too.May 30, 2016 at 3:57 pm #12797MichaelParticipantI had already rolled back to a different project using the same basic code. It had much older versions for mbed, rtos and libmdot
That did not fix the join problem.
I will try again.
Perhaps the corrupted flash is an issue
See: http://www.multitech.net/developer/forums/topic/lost-deviceid/May 30, 2016 at 4:37 pm #12798MichaelParticipantJ-
Goodness….
I sort of misread which library you were concerned with and rolled back differently
Now rtos: 117
mbed: 111
Libmdot: 14However…it seems to work now. I’ll dig a bit into it.
Thanks.
-M
-
AuthorPosts
- You must be logged in to reply to this topic.