Hot!Stimulus for UART receive & delays in stimulus file

Author
wave.jaco
New Member
  • Total Posts : 17
  • Reward points : 0
  • Joined: 2015/07/31 23:05:29
  • Location: South Africa
  • Status: offline
2018/06/27 00:06:14 (permalink)
0

Stimulus for UART receive & delays in stimulus file

Hi everybody
 
I am trying to use the Stimulus feature in MPLAB X v4.15 (with the XC32 v1.34 compiler) to simulate the reception of data over the UART to a PIC32MX250F128B. The stimulus works perfect in simulating the transmission of the data itself, but it seems to ignore the delays that I have in the file. For example, if I have the following stimulus file:
//Send initial data packet "FE"
"FE"

//wait for 10 seconds
wait 10 sec

//Send test data packet 1
90 03 7F

//wait for 5 seconds
wait 5 sec

//Send test data packet 2
90 03 00

the data gets received nearly all at once, i.e. without the delays in between. I have confirmed this by setting a break point in the source code where the last data packet (test data packet 2) would be processed, and the debugger reaches that point almost immediately after firing the stimulus.
 
The only workaround that I could use at the moment is to have a separate stimulus file for each data packet that need to be simulated, and fire each stimulus file entry manually. Although this works for small tests, it will get dirty very quickly if I have to simulate a lot of data packets (which is my intention), so I really need the stimulus feature to interpret and enforce the delays in the file.
 
Why is the stimulus ignoring the delays in the stimulus file?
#1

7 Replies Related Threads

    GeorgePauley
    Moderator
    • Total Posts : 998
    • Reward points : 0
    • Joined: 2009/12/01 13:59:30
    • Location: Chandler AZ
    • Status: offline
    Re: Stimulus for UART receive & delays in stimulus file 2018/06/27 08:39:16 (permalink)
    0
    PIC32 simulator will execute about 1 million instructions per second on most PCs.  The wait times in the data file are not real time they are simulated time. This means you can't just look at the clock on the wall to measure simulated time.  Take a look at the stopwatch within MPLAB to see how many cycles are going by between reception of characters to see if the simulator is actually waiting the appropriate number of cycles between characters.
     
    What is your Fosc value in the project settings under simulator tab?  Default is 1MHz.  In which case I would expect a 10s delay to be about 10 seconds of real time.  But if you bumped it down to say 32 kHz (a popular power saving speed) then I would expect 10 seconds of simulated time to be about 1/3 of a second real time.
    #2
    wave.jaco
    New Member
    • Total Posts : 17
    • Reward points : 0
    • Joined: 2015/07/31 23:05:29
    • Location: South Africa
    • Status: offline
    Re: Stimulus for UART receive & delays in stimulus file 2018/06/27 23:28:42 (permalink)
    0
    GeorgePauley
    PIC32 simulator will execute about 1 million instructions per second on most PCs.  The wait times in the data file are not real time they are simulated time. This means you can't just look at the clock on the wall to measure simulated time.  Take a look at the stopwatch within MPLAB to see how many cycles are going by between reception of characters to see if the simulator is actually waiting the appropriate number of cycles between characters.
     
    What is your Fosc value in the project settings under simulator tab?  Default is 1MHz.  In which case I would expect a 10s delay to be about 10 seconds of real time.  But if you bumped it down to say 32 kHz (a popular power saving speed) then I would expect 10 seconds of simulated time to be about 1/3 of a second real time.

    I have done a quick search in the help contents of MPLAB X and the only reference that I could find related to wait times and the stimulus is in the section titled Message-Based Data File Description. In that section (which I used as reference to write the stimulus file), it states that the unit of time to be waited can be specified as either ps, ns, us, ms, sec, min or hr. Does this then apply to a different use case of the stimulus (or other MPLAB X feature) than my use case? If this is not the case, then it seems that the help documentation in MPLAB X is incorrect or incomplete.
     
    Nevertheless, the oscillator setting in the simulator tab (Fcyc in my case) is indeed 1 MHz. Could you kindly explain how you calculate the simulated vs. real time delays for the two clock speeds that you mentioned (in the case of using the simulator)? I would like to properly understand how to calculate this so that I can accurately simulate time delays as per my testing requirements.
     
    It seems that the stopwatch feature is not available for the device that I am using (actually PIC32MX in general, it seems) when using the simulator. Also, when I specify Real ICE as the debugging tool, the stopwatch feature is now available, but the stimulus feature is then not available. Therefore, I could not use the stopwatch to determine the actual time the stimulus waits between sending the packets.
     
    UPDATE:
    As another test, I have even changed the delays in my stimulus files from a few seconds to over 3 hours between sending the packets, and this seems to have no difference at all. So there is either something very wrong or I am missing something very obvious...
    post edited by wave.jaco - 2018/06/27 23:42:05
    #3
    GeorgePauley
    Moderator
    • Total Posts : 998
    • Reward points : 0
    • Joined: 2009/12/01 13:59:30
    • Location: Chandler AZ
    • Status: offline
    Re: Stimulus for UART receive & delays in stimulus file 2018/06/28 09:55:33 (permalink)
    0
    I just tried this on my machine and the delays worked fine.  Can you provide a screenshot of your stimulus window so we can see exactly how you set it up?
     
    If Fcyc is 1MHz, then each instruction cycle takes 1us (1/1,000,000).  So if you ask the simulator to delays for 2 seconds it will execute 2 million instruction cycles.  (Not necessarily 2 million instructions as some instructions take more than 1 cycle to execute.)
    #4
    wave.jaco
    New Member
    • Total Posts : 17
    • Reward points : 0
    • Joined: 2015/07/31 23:05:29
    • Location: South Africa
    • Status: offline
    Re: Stimulus for UART receive & delays in stimulus file 2018/07/03 12:43:48 (permalink)
    0
    Herewith attached are screenshots of the stimulus setup, as well as the oscillator configuration in the debugger.
    post edited by wave.jaco - 2018/07/03 12:45:21

    Attached Image(s)

    #5
    GeorgePauley
    Moderator
    • Total Posts : 998
    • Reward points : 0
    • Joined: 2009/12/01 13:59:30
    • Location: Chandler AZ
    • Status: offline
    Re: Stimulus for UART receive & delays in stimulus file 2018/07/10 08:54:23 (permalink)
    +2 (2)
    You need to use the "Register Injection" tab, not "Asynchronous".  In particular, the magic here is to use "Message" trigger type.  Message trigger allows the simulator to choose when injections occur.  In this case, the UART will determine which instruction cycle to receive the next character, based on the selected baud rate.
     
    Asynchronous injection occurs immediately when you hit the blue button.

    Attached Image(s)

    #6
    wave.jaco
    New Member
    • Total Posts : 17
    • Reward points : 0
    • Joined: 2015/07/31 23:05:29
    • Location: South Africa
    • Status: offline
    Re: Stimulus for UART receive & delays in stimulus file 2018/07/11 00:38:34 (permalink)
    0
    Thank you for the clarification, George.
     
    I have been using the "Asynchronous" option all along. I will give the "Register Injection" option a try and provide feedback here.
    #7
    wave.jaco
    New Member
    • Total Posts : 17
    • Reward points : 0
    • Joined: 2015/07/31 23:05:29
    • Location: South Africa
    • Status: offline
    Re: Stimulus for UART receive & delays in stimulus file 2018/08/16 04:14:17 (permalink)
    +1 (1)
    Just some quick feedback regarding this matter - the "Register Injection" option works as advertised.
     
    Many thanks for all the assistance.
    #8
    Jump to:
    © 2018 APG vNext Commercial Version 4.5