PORTC.4 and C.5 not responding to inputs.


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Location
    Michigan, USA
    Posts
    305

    Default PORTC.4 and C.5 not responding to inputs.

    As usual, 18F2550. I am trying to use these ports as inputs. According to the datasheet, making UCON.3 = 0 turns off the USB and allows the pins to be used as inputs.

    I have a switch on each of these pins that goes high when pressed. Nothing happens within the program whenb pressed. What should I check for next?

    Code:
    Define OSC 8
    OSCCON=110000
    DEFINE ADC_BITS 10
    DEFINE ADC_CLOCK 3
    DEFINE ADC_SAMPLEUS 50
    
    
    DEFINE CCP1_REG PORTC 'Hpwm 1 pin port
    DEFINE CCP1_BIT 2     'Hpwm 1 pin bit
    
    
    ADCON1 = 001011
    ADCON2 = 001010
    
    
    TRISA = 111111
    TRISB = 000000
    TRISC = 110001
    
    CMCON = 7
    UCON.3 = 0
    
    portc.1 = 0
    
    alpha var byte
    PCBTEMP var word
    CURRENT var word
    LEDS var byte
    alpha = 0
    LEDS = 0
    pcbtemp = 0
    
    ;--- The Main Loop ---------------------------------------------------------
    'HPWM 1,1,10000 
    LOOP1:
    porta.6 = 1
    alpha = alpha + 10
    if alpha = 250 then
    alpha = 0
    endif
    HPWM 1,alpha,30000
    pause 200
    IF portc.4 = 1 and LEDS <5 then 'portc.4 = number of LED's lit goes up (0-5LED'S)
    pause 100
    LEDS = LEDS + 1
    pause 100
    endif
    
    
    
    
    IF portc.5 = 1 and LEDS >0 then  'portc.5 = number of LED's lit goes down (5-0LED'S)
    pause 100
    LEDS = LEDS - 1
    'IF LEDS = 0 then 
    'LEDS = 0
    pause 100
    'endif
    endif
    
    
    IF LEDs = 0 then
    portb.1 = 0
    portb.2 = 0
    portb.3 = 0
    portb.4 = 0
    portb.5 = 0
    endif
    
    
    IF LEDs = 1 then
    portb.1 = 0
    portb.2 = 0
    portb.3 = 0
    portb.4 = 0
    portb.5 = 1
    endif
    
    
    IF LEDs = 2 then
    portb.1 = 0
    portb.2 = 0
    portb.3 = 0
    portb.4 = 1
    portb.5 = 1
    endif
    
    
    IF LEDs = 3 then
    portb.1 = 0
    portb.2 = 0
    portb.3 = 1
    portb.4 = 1
    portb.5 = 1
    endif
    
    
    IF LEDs = 4 then
    portb.1 = 0
    portb.2 = 1
    portb.3 = 1
    portb.4 = 1
    portb.5 = 1
    endif
    
    
    IF LEDs = 5 then
    portb.1 = 1
    portb.2 = 1
    portb.3 = 1
    portb.4 = 1
    portb.5 = 1
    endif
    
    
    GOTO LOOP1

  2. #2
    Join Date
    Feb 2004
    Location
    Michigan, USA
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: PORTC.4 and C.5 not responding to inputs.

    Ok, I hate it when this happens because you look like such a fool!

    UCFG.3 = 1 (this turns off the USB Transceiver which you also have to do to enable RC4 and RC5 as inputs.)


  3. #3
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,588


    Did you find this post helpful? Yes | No

    Default Re: PORTC.4 and C.5 not responding to inputs.

    I can delete the thread for you if it makes you happy.

    I'm kidding, this could help someone else. Configs can be such a pain sometimes.

    In an ideal world, PICs would know what we want even when we don't. LOL

    Robert



    EDIT:

    Ok, I hate it when this happens because you look like such a fool!
    Only if you start an identical thread tomorrow!

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts