Simple PORTB operation with logic analyzer does not work.

Author
elac@online.be
New Member
  • Total Posts : 13
  • Reward points : 0
  • Joined: 2011/08/24 07:11:07
  • Location: 0
  • Status: offline
2013/09/21 02:52:56 (permalink)
0

Simple PORTB operation with logic analyzer does not work.

hi all,
 
I'm trying to get the logic analyzer to work properly with this quite easy program.
The simulation with variables-tracing is working fine, but the logic analyzer only shows the correct signals for the 3 MSBits of PORTB.... WHY ???
 
I'm using MPLAB X V1.90
 

#1

12 Replies Related Threads

    kevcon
    Super Member
    • Total Posts : 568
    • Reward points : 0
    • Joined: 2011/09/16 07:34:49
    • Location: 0
    • Status: offline
    Re:Simple PORTB operation with logic analyzer does not work. 2013/09/21 06:39:12 (permalink)
    0
    What chip are you using?

    Go ahead, use a UNION for that, it's okay.
    #2
    elac@online.be
    New Member
    • Total Posts : 13
    • Reward points : 0
    • Joined: 2011/08/24 07:11:07
    • Location: 0
    • Status: offline
    Re:Simple PORTB operation with logic analyzer does not work. 2013/09/21 06:43:34 (permalink)
    0
    Ah sorry :-) indeed :
     
    PIC18F2455
    C18 compiler V3.4x
    #3
    kevcon
    Super Member
    • Total Posts : 568
    • Reward points : 0
    • Joined: 2011/09/16 07:34:49
    • Location: 0
    • Status: offline
    Re:Simple PORTB operation with logic analyzer does not work. 2013/09/21 06:58:52 (permalink)
    +1 (1)
    add

    ADCON1 = 0xFF;
    to your code and see if that helps

    Go ahead, use a UNION for that, it's okay.
    #4
    elac@online.be
    New Member
    • Total Posts : 13
    • Reward points : 0
    • Joined: 2011/08/24 07:11:07
    • Location: 0
    • Status: offline
    Re:Simple PORTB operation with logic analyzer does not work. 2013/09/21 07:30:29 (permalink)
    0
    This will not do it because the complete port is output (TRISB=0)
     
    If it's input, then yes, the port pin's should be defined as Digital Inputs. with the adcon1 register.
     
    So; Not appliable here wink
     
    **  BUT IT HELPED  **
    ?????????????????????
     
    Why ?
    ADCON1 is only necessary when using the port as INPUT ? not ??
    post edited by elac@online.be - 2013/09/21 07:43:54
    #5
    1and0
    Access is Denied
    • Total Posts : 6836
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re:Simple PORTB operation with logic analyzer does not work. 2013/09/21 07:45:18 (permalink)
    +1 (1)
    elac@online.be
    This will not do it because the complete port is output (TRISB=0)
    If it's input, then yes, the port pin's should be defined as Digital Inputs. with the adcon1 register.
    So; Not appliable here wink
    Thanks for the suggestion...
    In the "real" hardware maybe, but this is the SIMulator.  Try what kevcon suggested (or ADCON1=0x0F) you'll be surprised!
     
    <edit> On second thought, IIRC the config bit PBADEN has precedence.  Try setting PBADEN = OFF and see.
    <edit2> Remove strikethrough of my first statement, and add strikethrough on <edit>.
     
    post edited by 1and0 - 2013/09/22 12:43:23
    #6
    elac@online.be
    New Member
    • Total Posts : 13
    • Reward points : 0
    • Joined: 2011/08/24 07:11:07
    • Location: 0
    • Status: offline
    Re:Simple PORTB operation with logic analyzer does not work. 2013/09/21 08:09:22 (permalink)
    0
    Hi,
     
    yes, I modified my reply shortly after (tought it should at least be tried)
     
    Still ... I wonder why the ADCON1 had to be 0xFF .... :-s
     
    #7
    elac@online.be
    New Member
    • Total Posts : 13
    • Reward points : 0
    • Joined: 2011/08/24 07:11:07
    • Location: 0
    • Status: offline
    Re:Simple PORTB operation with logic analyzer does not work. 2013/09/21 23:53:47 (permalink)
    0
    Hi 1and0,
     
    At this point, the students do not set the configuration bits yet...
    It is indeed strange that the simulator needs to be told that portb is not used as analog input, tough the port is set as output.
     
    This must be a bug in the simulator-part of mplab-x
     
     
    greetz all and much thanks for the contribution !!
    #8
    1and0
    Access is Denied
    • Total Posts : 6836
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re:Simple PORTB operation with logic analyzer does not work. 2013/09/22 08:27:48 (permalink)
    +1 (1)
    elac@online.be
    At this point, the students do not set the configuration bits yet...
    It is indeed strange that the simulator needs to be told that portb is not used as analog input, tough the port is set as output.
    As I said in Post #6, the PBADEN configuration bit has precedence.  This config bit is default to configure PORTB<4:0> pins as analog inputs on Reset, and it seems to override the TRISB register.  So to use these PORTB pins as digital I/O, you have two choices:
     
    1.  set the config bit PBADEN = OFF, or
    2.  configure the ADCON1 register accordingly.

    This must be a bug in the simulator-part of mplab-x
    In this case, I don't think it's a bug.   <edit> see below.
    post edited by 1and0 - 2013/09/22 12:45:12
    #9
    elac@online.be
    New Member
    • Total Posts : 13
    • Reward points : 0
    • Joined: 2011/08/24 07:11:07
    • Location: 0
    • Status: offline
    Re:Simple PORTB operation with logic analyzer does not work. 2013/09/22 10:25:33 (permalink)
    0
    Hi 1and0,
     
    I do not agree.
     
    The TRISB=0 overrides input-settings anyway as we set the port for OUTPUT. This has no impact on A/D-settings wich become necessary to verify e.g. if TRISB=255.
     
    greetz
    #10
    dan1138
    Super Member
    • Total Posts : 2541
    • Reward points : 0
    • Status: offline
    Re:Simple PORTB operation with logic analyzer does not work. 2013/09/22 11:34:06 (permalink)
    0
    elac@online.be is justified in calling this a simulator bug in so far as the simulated behavior does not match what occurs with the real hardware.
     
    Your initial question: "... the logic analyzer only shows the correct signals for the 3 MSBits of PORTB.... WHY ??? "
     
    The cause is the logic analyzer is capturing the PORTB bits not the LATB bits. This is a problem because the logic analyzer sees PORTB in the same context as your application does.
     
    I can just hear you saying: "What the @#%& does that mean?"
     
    It means that the logic analyzer does not see the state of the pin in the same way as the hardware works.
     
    In general this is a "bug" but can be viewed as useful in that when the logic analyzer captures what you expect then the firmware will behave as simulated in the real hardware. Even this statement has a yea but. There are some obscure bugs with the timer function blocks where the timers resume counting from the internal clock source too soon after a write to the timer count registers. If any of these bugs are known to Microchip I have not seen any reference to them in any of the release notes for MPLAB.
     
    The ADC simulation model has never been complete or correct.  It has various bugs. The only safe thing you can do is to initialize it then disable it. For some targets you must use the wrong values to initialize it with when using the simulator. (http://www.microchip.com/forums/fb.ashx?m=603574)
    post edited by dan1138 - 2013/09/22 12:43:02
    #11
    1and0
    Access is Denied
    • Total Posts : 6836
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re:Simple PORTB operation with logic analyzer does not work. 2013/09/22 12:39:28 (permalink)
    0
    dan1138
    elac @ online.be is justified in calling this a simulator bug in so far as the simulated behavior does not match what occurs with the real hardware.
    I stand corrected then.  So my initial statement in Post #6
    1and0In the "real" hardware maybe, but this is the SIMulator.
    was correct.  Pins configured as output are not affected by analog input.
     
    Going to remove the strikethrough of that statement in Post #6 and re-edit my posts.
    #12
    elac@online.be
    New Member
    • Total Posts : 13
    • Reward points : 0
    • Joined: 2011/08/24 07:11:07
    • Location: 0
    • Status: offline
    Re:Simple PORTB operation with logic analyzer does not work. 2013/09/22 21:21:49 (permalink)
    +1 (1)
    Hi dan1138
     
    Thanks for youre reply. Basicaly you're talking about the read-modify-write problem, wich only occurs in real circuits. Simple simulators (like the one embedded in mplabx) should not have to misbehave.
     
    I believe µchip has a lot of work to do on this simulator. I wouldn't mind they concentrated the developping crew on the simulator because it is realy, realy basic comared to e.g. the Fored's Wiz-C.
     
     
    Anyway, I now know that the simulator is no good, not reliable, and one should experiment changing parameters where we don't expect them to be changed pink.
    ANother interesting point is the simulation speed : 15x to slow....... arf !
     
     
    greetz Smile
    #13
    Jump to:
    © 2017 APG vNext Commercial Version 4.5