ticker / timer

Home Forums mDot/xDot ticker / timer

Tagged: , ,

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #12736
    Michael
    Participant

    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?

    • This topic was modified 8 years, 6 months ago by Michael.
    • This topic was modified 8 years, 6 months ago by Michael.
    • This topic was modified 8 years, 6 months ago by Michael.
    #12742
    Mike Fiore
    Blocked

    Michael,

    I’m surprised that code compiles. You’re not creating the DigitalOut object correctly. It should be

    
    DigitalOut led(PA_1);
    

    Cheers,

    -Mike

    #12744
    Michael
    Participant

    Compiles fine.

    I can flash the LED “manually”.

    So it works, too.

    I cannot get the timer-ticker to work. That’s my problem.

    -Mike

    #12746
    Mike Fiore
    Blocked

    Michael,

    Is your mDot in a UDK2 board? It would look like the board on this page:
    http://www.multitech.com/brands/mdot-devkit

    If 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

    #12748
    Michael
    Participant

    Hi 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
    Mike

    #12749
    Mike Fiore
    Blocked

    Michael,

    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

    #12761
    Michael
    Participant

    First: 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?

    #12768
    Mike Fiore
    Blocked

    Michael,

    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

    #12786
    Michael
    Participant

    Understood. At least I have some idea *what* is in my way, if not *why* atm.

    My revisions are:

    libmdot: 14
    mbed: 117
    mbed-rtos: 121

    #12796
    Jason Reiss
    Keymaster

    There have been issues with mbed-rtos 117.
    Rollback to a previous version. This should fix the join issue too.

    #12797
    Michael
    Participant

    I 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/

    #12798
    Michael
    Participant

    J-

    Goodness….

    I sort of misread which library you were concerned with and rolled back differently

    Now rtos: 117
    mbed: 111
    Libmdot: 14

    However…it seems to work now. I’ll dig a bit into it.

    Thanks.

    -M

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.