Hot!peripheral speed when single stepping ?

Author
paul__b
Starting Member
  • Total Posts : 34
  • Reward points : 0
  • Joined: 2013/11/09 04:33:47
  • Location: 0
  • Status: offline
2017/09/13 10:07:26 (permalink)
0

peripheral speed when single stepping ?

Hi I am a bit confused with a thing someone must know about.
I am using 16f18854 with mplabx (assembler), I have an ADC that triggers an interrupt when conversion complete.
I require some code to run while the ADC is doing its conversion, and then wait in a loop until the ISR gets triggered.
I think from counting the clock cycles that there is enough time for the code to get to the wait loop; also if use some diagnostic outputs on spare pins there seems to be spare time  with the programme waiting in the wait loop before the ISR starts.
However if I single step through the programme there is not enough time for the code to complete before the ISR starts.
Do peripherals have correct timing relationship to the programme when single steping ?
 
#1

4 Replies Related Threads

    GeorgePauley
    Moderator
    • Total Posts : 860
    • Reward points : 0
    • Joined: 2009/12/01 13:59:30
    • Location: Chandler AZ
    • Status: offline
    Re: peripheral speed when single stepping ? 2017/09/13 10:44:38 (permalink)
    +2 (2)
    Likely you don't have freeze peripherals set.  (Project Properties - Your Tool (e.g. ICD3) - Freeze Peripherals.)  When Freeze peripherals is off, the peripherals will continue working while the target is halted.  This is generally a preferred state as you don't want to miss external events such as receiving a character on the UART.  But if you freeze peripherals then the ADC should halt along with the processor.
    #2
    paul__b
    Starting Member
    • Total Posts : 34
    • Reward points : 0
    • Joined: 2013/11/09 04:33:47
    • Location: 0
    • Status: offline
    Re: peripheral speed when single stepping ? 2017/09/14 01:51:54 (permalink)
    0
    Thanks George, I was not really familiar with that selection option, however it does not solve the problem.  It was already set to freeze. I If I don't set freeze peripherals, then as soon as the ISR is completed it re triggers the ISR as you would expect because the ADC is done in about 10us.
    If I set freeze, then it is possible to step through many instructions before the ISR gets called again, however not enough for the routine to complete. But if I look at what is happening on a scope, at full speed, then things happen as I would expect, there is plenty of time for the routine to complete before the ISR gets called again.
    There seem to be some comments about freeze peripherals not working properly, is it generaly accepted that this should work OK with mplabx 3.65 and ICD3 ?   (I was originally using pickit3 but it is no different with ICD3)
    Many thanks Paul
     
    #3
    NJT
    Starting Member
    • Total Posts : 28
    • Reward points : 0
    • Status: offline
    Re: peripheral speed when single stepping ? 2017/09/14 10:06:22 (permalink)
    0
    Paul,
     
           What clock source are you using for the ADC in this case?  The Freeze feature works a little bit differently with asynchronous peripherals (say if the ADC is using its dedicated ADRC) than it does with synchronous functions.  Specifically it won't clip the clock of the asynchronous peripheral.  As such, single-stepping may only perform 1 instruction from the CPU side, but at the same time an entire ADRC clock will execute from the perspective of the ADC.  
     
    In the example of the ADRC, this would cause the ADC to trigger after 12 single steps (as that would also cause 12 TADs to occur due to the aforementioned lack of clock clipping), while full speed would allow both the CPU clock and the ADRC to occur at their normal expected speeds.  This could explain the behavior you are seeing.  

    "In the beginning, the universe was created.  
    This has made a lot of people very angry and been widely regarded as a bad move." 
    -Douglas Adams
    #4
    paul__b
    Starting Member
    • Total Posts : 34
    • Reward points : 0
    • Joined: 2013/11/09 04:33:47
    • Location: 0
    • Status: offline
    Re: peripheral speed when single stepping ? 2017/09/15 06:11:42 (permalink)
    0
    Thanks NJT,
    It is a synchronous clock, should have mentioned that.
    the CPU is at max rate 0.125us / instruction and the ADC is on divided system clock at max rate of about 11us for a complete conversion.  Conversions every ~16 us. It seems to take around 50 clock cycles  for a conversion (some instructions take 2 cycles).
    Seems to work in real life, just not surewhat to expect from debugger.
    Paul
    #5
    Jump to:
    © 2017 APG vNext Commercial Version 4.5