Loading ...
Sorry, an error occurred while loading the content.

Help needed with the PIC 16F747 / 16F777

Expand Messages
  • Bob Hyland, PMP
    I left this message for the PICList, but I cannot seem to get the moderator to add me to the group. Perhaps someone here can help unravel this mystery: I am
    Message 1 of 3 , Dec 1, 2005
    • 0 Attachment
      I left this message for the PICList, but I cannot seem to get the
      moderator to add me to the group. Perhaps someone here can help
      unravel this mystery:

      I am seeing strange results using a PIC 16F747 (or a 16F777). I have
      the following code segment, which I have made very simple to try to
      determine why I have this issue. I have deactivated the CCP modules
      (CLRF CCP1CON, CCP2CON, CCP3CON), assigned the A/D pins to I/O (CLRF
      ADCON0, ADCON1, ADCON2), switched off the comparator module (CMCON =
      0x07), enabled all the weak pull-ups (BCF 0x81,RBPU), and made pins
      0-6 on PORTB outputs (TRISB = 0b10000000).

      Now, I simply monitor pin 7, and make each other pin on PORTB match
      the value in polling manner. I attach 2 random PORTB pins to LED's
      through (current limiting) resistors to the +5 rail.

      The result? Here is what shows on my 'scope when I monitor any of
      the 7 output pins and pin 7 is high:

      --------_--------_--------_---------_

      What gives? I am baffled. I want it to be high when pin-7 is high,
      and low when pin-7 is low. What am I missing?

      Any help would be greatly appreciated. Code snippet follows.


      m004 BCF 0x03,RP0
      BCF 0x03,RP1
      ; out6 = in_7;
      BTFSS 0x06,in_7
      BCF 0x06,out6
      BTFSC 0x06,in_7
      BSF 0x06,out6
      ; out5 = in_7;
      BTFSS 0x06,in_7
      BCF 0x06,out5
      BTFSC 0x06,in_7
      BSF 0x06,out5
      ; out4 = in_7;
      BTFSS 0x06,in_7
      BCF 0x06,out4
      BTFSC 0x06,in_7
      BSF 0x06,out4
      ; out3 = in_7;
      BTFSS 0x06,in_7
      BCF 0x06,out3
      BTFSC 0x06,in_7
      BSF 0x06,out3
      ; out2 = in_7;
      BTFSS 0x06,in_7
      BCF 0x06,out2
      BTFSC 0x06,in_7
      BSF 0x06,out2
      ; out1 = in_7;
      BTFSS 0x06,in_7
      BCF 0x06,out1
      BTFSC 0x06,in_7
      BSF 0x06,out1
      ; out0 = in_7;
      BTFSS 0x06,in_7
      BCF 0x06,out0
      BTFSC 0x06,in_7
      BSF 0x06,out0

      GOTO m004 ; Never stop


      Thank you,

      Bob H.
    • rtstofer
      From the datasheet re: PORTA, ADCON1 = 0x0f for digital IO. PORTB has analog inputs so setting ADCON1 = 0x00 would be a problem for PORTB even if we don t
      Message 2 of 3 , Dec 1, 2005
      • 0 Attachment
        From the datasheet re: PORTA, ADCON1 = 0x0f for digital IO. PORTB
        has analog inputs so setting ADCON1 = 0x00 would be a problem for
        PORTB even if we don't care about PORTA.

        There is usually a hangup with the analog converter, analog
        comparator and digital IO. Read over the sections in the manual
        carefully. Why these pins default to analog, I will never
        understand.

        Richard

        --- In Electronics_101@yahoogroups.com, "Bob Hyland, PMP"
        <BobHyland@A...> wrote:
        >
        > I left this message for the PICList, but I cannot seem to get the
        > moderator to add me to the group. Perhaps someone here can help
        > unravel this mystery:
        >
        > I am seeing strange results using a PIC 16F747 (or a 16F777). I
        have
        > the following code segment, which I have made very simple to try
        to
        > determine why I have this issue. I have deactivated the CCP
        modules
        > (CLRF CCP1CON, CCP2CON, CCP3CON), assigned the A/D pins to I/O
        (CLRF
        > ADCON0, ADCON1, ADCON2), switched off the comparator module (CMCON
        =
        > 0x07), enabled all the weak pull-ups (BCF 0x81,RBPU), and made
        pins
        > 0-6 on PORTB outputs (TRISB = 0b10000000).
        >
        > Now, I simply monitor pin 7, and make each other pin on PORTB
        match
        > the value in polling manner. I attach 2 random PORTB pins to LED's
        > through (current limiting) resistors to the +5 rail.
        >
        > The result? Here is what shows on my 'scope when I monitor any of
        > the 7 output pins and pin 7 is high:
        >
        > --------_--------_--------_---------_
        >
        > What gives? I am baffled. I want it to be high when pin-7 is high,
        > and low when pin-7 is low. What am I missing?
        >
        > Any help would be greatly appreciated. Code snippet follows.
        >
        >
        > m004 BCF 0x03,RP0
        > BCF 0x03,RP1
        > ; out6 = in_7;
        > BTFSS 0x06,in_7
        > BCF 0x06,out6
        > BTFSC 0x06,in_7
        > BSF 0x06,out6
        > ; out5 = in_7;
        > BTFSS 0x06,in_7
        > BCF 0x06,out5
        > BTFSC 0x06,in_7
        > BSF 0x06,out5
        > ; out4 = in_7;
        > BTFSS 0x06,in_7
        > BCF 0x06,out4
        > BTFSC 0x06,in_7
        > BSF 0x06,out4
        > ; out3 = in_7;
        > BTFSS 0x06,in_7
        > BCF 0x06,out3
        > BTFSC 0x06,in_7
        > BSF 0x06,out3
        > ; out2 = in_7;
        > BTFSS 0x06,in_7
        > BCF 0x06,out2
        > BTFSC 0x06,in_7
        > BSF 0x06,out2
        > ; out1 = in_7;
        > BTFSS 0x06,in_7
        > BCF 0x06,out1
        > BTFSC 0x06,in_7
        > BSF 0x06,out1
        > ; out0 = in_7;
        > BTFSS 0x06,in_7
        > BCF 0x06,out0
        > BTFSC 0x06,in_7
        > BSF 0x06,out0
        >
        > GOTO m004 ; Never stop
        >
        >
        > Thank you,
        >
        > Bob H.
        >
      • Bob Hyland, PMP
        Went back & read that section. Made a simple change and IT WORKED! Thank you! ... the ... (CMCON ... LED s ... of ... high,
        Message 3 of 3 , Dec 1, 2005
        • 0 Attachment
          Went back & read that section. Made a simple change and IT WORKED!

          Thank you!

          --- In Electronics_101@yahoogroups.com, "rtstofer" <rstofer@p...>
          wrote:
          >
          >
          > From the datasheet re: PORTA, ADCON1 = 0x0f for digital IO. PORTB
          > has analog inputs so setting ADCON1 = 0x00 would be a problem for
          > PORTB even if we don't care about PORTA.
          >
          > There is usually a hangup with the analog converter, analog
          > comparator and digital IO. Read over the sections in the manual
          > carefully. Why these pins default to analog, I will never
          > understand.
          >
          > Richard
          >
          > --- In Electronics_101@yahoogroups.com, "Bob Hyland, PMP"
          > <BobHyland@A...> wrote:
          > >
          > > I left this message for the PICList, but I cannot seem to get
          the
          > > moderator to add me to the group. Perhaps someone here can help
          > > unravel this mystery:
          > >
          > > I am seeing strange results using a PIC 16F747 (or a 16F777). I
          > have
          > > the following code segment, which I have made very simple to try
          > to
          > > determine why I have this issue. I have deactivated the CCP
          > modules
          > > (CLRF CCP1CON, CCP2CON, CCP3CON), assigned the A/D pins to I/O
          > (CLRF
          > > ADCON0, ADCON1, ADCON2), switched off the comparator module
          (CMCON
          > =
          > > 0x07), enabled all the weak pull-ups (BCF 0x81,RBPU), and made
          > pins
          > > 0-6 on PORTB outputs (TRISB = 0b10000000).
          > >
          > > Now, I simply monitor pin 7, and make each other pin on PORTB
          > match
          > > the value in polling manner. I attach 2 random PORTB pins to
          LED's
          > > through (current limiting) resistors to the +5 rail.
          > >
          > > The result? Here is what shows on my 'scope when I monitor any
          of
          > > the 7 output pins and pin 7 is high:
          > >
          > > --------_--------_--------_---------_
          > >
          > > What gives? I am baffled. I want it to be high when pin-7 is
          high,
          > > and low when pin-7 is low. What am I missing?
          > >
          > > Any help would be greatly appreciated. Code snippet follows.
          > >
          > >
          > > m004 BCF 0x03,RP0
          > > BCF 0x03,RP1
          > > ; out6 = in_7;
          > > BTFSS 0x06,in_7
          > > BCF 0x06,out6
          > > BTFSC 0x06,in_7
          > > BSF 0x06,out6
          > > ; out5 = in_7;
          > > BTFSS 0x06,in_7
          > > BCF 0x06,out5
          > > BTFSC 0x06,in_7
          > > BSF 0x06,out5
          > > ; out4 = in_7;
          > > BTFSS 0x06,in_7
          > > BCF 0x06,out4
          > > BTFSC 0x06,in_7
          > > BSF 0x06,out4
          > > ; out3 = in_7;
          > > BTFSS 0x06,in_7
          > > BCF 0x06,out3
          > > BTFSC 0x06,in_7
          > > BSF 0x06,out3
          > > ; out2 = in_7;
          > > BTFSS 0x06,in_7
          > > BCF 0x06,out2
          > > BTFSC 0x06,in_7
          > > BSF 0x06,out2
          > > ; out1 = in_7;
          > > BTFSS 0x06,in_7
          > > BCF 0x06,out1
          > > BTFSC 0x06,in_7
          > > BSF 0x06,out1
          > > ; out0 = in_7;
          > > BTFSS 0x06,in_7
          > > BCF 0x06,out0
          > > BTFSC 0x06,in_7
          > > BSF 0x06,out0
          > >
          > > GOTO m004 ; Never stop
          > >
          > >
          > > Thank you,
          > >
          > > Bob H.
          > >
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.