simulationstm32renode

RENODE How press a button for 5s and invert the methods Press and Release to be compatible with button with pullup configuration


I want to simulate in RENODE my stm32f030 to pressing a button for 5 seconds. But I have some problems related to the time and also with the RENODE method to simulate a Press and a Release of the button

In my firmware I configured the pin that is connected to the button as pull-up, that is, the button without pressing it has Status=TRUE. When the button is pressed, it goes to GND and Status=FALSE.

I did a 'debug' in the RENODE methods, I simulate a Press and then with the Pressed method it returns the status, you can check that:

enter image description here

Is there a possibility to reverse this method? Or do I put it as an alias in the robot framework? I found very little documentation, any light on my problem is already welcome

About the problem with time, when I execute the Press method and then the Release method and wait for close to 20 seconds it executes the action which is to blink together the Red and Blue LEDs, see below. However in my firmware it is configured to occur an interruption in the timer after 5s.

enter image description here

I read a bit about this in the official documentation (https://renode.readthedocs.io/en/latest/advanced/time_framework.html) and I suspect it is related to this, but I haven't identified what I need to do to fix it.


Solution

  • Reversing the state of a button is quite easy.

    As in the miv-board.repl file, you can do the following:

    user_switch_0: Miscellaneous.Button @ gpioInputs 0
        invert: true  <--- this is relevant here
        -> gpioInputs@0
    

    Regarding time flow, Renode operates in virtual time domain to ensure determinism of execution, regardless of the host machine. It can be similar to real time flow, but depends heavily on the type of application you run. If you poll a lot and not use interrupts to sleep - things will be slower.

    To get information about current virtual time you can run emulation GetTimeSourceInfo and see the output like this:

    (machine) emulation GetTimeSourceInfo 
    Elapsed Virtual Time: 00:00:00.304409 <--- you want this to be 5s
    Elapsed Host Time: 00:00:00.831891
    Current load: 2.5
    Cumulative load: 2.73280684868056
    State: WaitingForReportBack
    Advance immediately: False
    Quantum: 00:00:00.000100