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






Bookmarks