16f690 portc problem

Discussion in 'Programmer's Corner' started by Dodgydave, Jul 6, 2012.

  1. Dodgydave

    Thread Starter Distinguished Member

    Jun 22, 2012
    4,969
    744
    I am using PORTC to run a series of leds from RC0 to RC7 and back just like the Knight rider display, i can get it to work up and down from RC0 to RC5 ok, but when i set it to use bits 6&7 it stops at RC6.

    is there some other setting to enable bits 6&7 to work, i have looked at the SSPCON register (page 159) in the datasheet and noticed bits 0-3,5 are mentioned.

    so i tried this line>> movlw b'00000101' 'in either Bank1 or Bank0'
    ............................movwf SSPCON

    and still no joy???

    any clues...?
     
  2. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    As far as I can tell from the datasheet, the default setting of 0x00 for SSPCON should allow the pins to be used as digital outputs. As long as bit 5, SSPEN is clear you should be OK.
    SSPCON is only in bank 0, if you are in bank 1 then you will be modifying SSPSTAT instead.
    What is your initialisation code?
     
  3. Dodgydave

    Thread Starter Distinguished Member

    Jun 22, 2012
    4,969
    744
    well i dont know what i have done, but its now working if i put the line in clrf ANSELH
     
  4. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    ANSELH controls digital/analog IO on AN8,9,10 and 11.
    AN8 and 9 are on PORTC 6 and 7 so it makes perfect sense that clearing them would have some part in fixing it.
     
Loading...