• AVR Freaks

Hot!Simulate FERR on PIC16F1779?

Author
johndpar
New Member
  • Total Posts : 14
  • Reward points : 0
  • Joined: 2007/04/26 05:33:39
  • Location: 0
  • Status: offline
2020/11/19 09:47:41 (permalink)
4 (1)

Simulate FERR on PIC16F1779?

Hi
 
Is it possible to simulate a framing error?
 
I've tried a few things including pulsing the RX pin low for about 2 character times using an Async stimulus and using a Pin/Register Action to force the bit directly, but without success.
 
MPLAB 5.45 on Linux x64
 
Any ideas?
 
Thanks
 
John
post edited by johndpar - 2020/11/19 10:19:12
#1

6 Replies Related Threads

    GeorgePauley
    Moderator
    • Total Posts : 1275
    • Reward points : 0
    • Joined: 2009/12/01 13:59:30
    • Location: Chandler AZ
    • Status: offline
    Re: Simulate FERR on PIC16F1779? 2020/11/20 10:04:28 (permalink)
    0 (2)
    The simulator doesn't model the UART at the pin level.  So bouncing the (UART) pins won't do much in the simulator.

    You can simply set the FERR signal.  First and easiest way is to put RC1STA in the MPLAB X watch window.  Then, at a time of your choosing, simply set RC1STA.FERR to the desired value inside the watch window. 
     
    The short fall of the watch window approach is that you have to manually set a breakpoint and manually set the FERR bit each time.  An alternative approach, though a bit more involved, is to use SCL to set FERR. SCL is a VHDL-like scripting language that is used to automatically inject register and pin values, at user defined points, into a simulator session.  You can find a good user's guide to SCL in the docs sub directory of your MPLAB X installation.  Once you've set up your SCL script to your needs, it will automatically be ran each debug session.
    #2
    ric
    Super Member
    • Total Posts : 28967
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Simulate FERR on PIC16F1779? 2020/11/20 13:12:39 (permalink)
    0
    GeorgePauley
    You can simply set the FERR signal.  First and easiest way is to put RC1STA in the MPLAB X watch window.  Then, at a time of your choosing, simply set RC1STA.FERR to the desired value inside the watch window. 

    Isn't that what he was trying when he said:
    "using a Pin/Register Action to force the bit directly"

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #3
    johndpar
    New Member
    • Total Posts : 14
    • Reward points : 0
    • Joined: 2007/04/26 05:33:39
    • Location: 0
    • Status: offline
    Re: Simulate FERR on PIC16F1779? 2020/11/21 00:19:58 (permalink)
    0
    Hi George and Ric
    Thanks for this. I had tried setting the FERR bit using the Pin/Register Actions, but I'm guessing that that alone will not fire the interrupt.
    What I'm trying to simulate is a break condition on the receive line, i.e. a low signal for a couple of character times, which would normally generate a framing error.
    This is the beginning of a DMX protocol frame. After the break condition, there is a sequence of bytes.
    My code is waiting for the UART interrupt to check the the FERR bit and advance the receive state variable to the next value. The breakpoint in the IRQ handler never fires.
     
    I tried setting the FERR bit using the Watches window and the bit just gets cleared again immediately.
     
    Any suggestions?
     
    Kind regards
    John
    post edited by johndpar - 2020/11/21 00:23:24
    #4
    ric
    Super Member
    • Total Posts : 28967
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Simulate FERR on PIC16F1779? 2020/11/21 00:39:44 (permalink)
    0
    The interrupt is triggered by RCIF getting set, not FERR. FERR is just like a parity bit.
    So as well as setting the FERR bit, you will need to simulate 0x00 being received as well.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #5
    GeorgePauley
    Moderator
    • Total Posts : 1275
    • Reward points : 0
    • Joined: 2009/12/01 13:59:30
    • Location: Chandler AZ
    • Status: offline
    Re: Simulate FERR on PIC16F1779? 2020/11/21 07:46:04 (permalink)
    +1 (1)
    Sorry gang, didn't notice the desired interrupt aspect.  Just set the interrupt flag at the same time you set the FERR flag and the interrupt will occur.  Assuming the interrupt is properly enabled, etc.
    #6
    johndpar
    New Member
    • Total Posts : 14
    • Reward points : 0
    • Joined: 2007/04/26 05:33:39
    • Location: 0
    • Status: offline
    Re: Simulate FERR on PIC16F1779? 2020/11/21 13:08:15 (permalink)
    +1 (1)
    Great - that worked! Thanks George
    I've stepped through the code and all seems good.
    Kind regards
    John
    #7
    Jump to:
    © 2020 APG vNext Commercial Version 4.5