James & Iliana Holbrook wrote: > > Greetings, > I've been messing with PIC's for some time but have laid off for the last 8 > months while I attend school. School's over so I'm back to PIC'n. > My first project is a typical counter using 4 LED's multiplexed, I'm using > PortB for drives and 4 pins of PortA to select the digit that is on. The > problem is that I can't get the program to see my switch. I've pulled it up > with a 10k resistor and a logic probe shows a good signal from the switch. > Funny thing is that if I pull the wire and test the porta pin 4 (RA4) I get a > pulse signal just like the other pins. I've read the data sheet but my brain is > pretty fried at this time due to intense schooling. > some snippets from my code follow. > Can someone point out my errant ways ? I'm using tris instead of trisb or > trisa because that's the way I learned. > > ;------- disp.asm ---------------------- > > list p=16c84 > radix hex > include "p16c84.inc" > > ;------- equates ----------------------- > > CBLOCK 0x0C > count, count1, count2, count3, count4 > disp1, disp2, disp3, disp4 > btn, flag, digit, comm > ENDC > > #define butn PORTA, 0x04 > #define zero STATUS, 0x02 > #define btnflg flag, 0 > #define incflg flag, 1 > > ;------- program code ------------------ > > org 0x00 > > start movlw 0x00 ; Initialize Portb > TRIS PORTB ; All Outputs > movlw 0x10 ; Initialize Porta > TRIS PORTA ; 0,1,2,3 are output, 4 is input > movlw b'01110' ; set so first digit is visible > movwf digit > movlw B'00111111' ; set to display zero > clrf comm ; clear counter > main movwf PORTB > movf digit, w > movwf PORTA > call digcnt ; Call digit count routine > btfsc butn ; is button down ? > btfss butn ; is button down ? > bsf btnflg ; set flag if not > btfss butn ; test again > call btndn ; button down routine gets called > btfsc incflg ; check to see if increment is due > call inccnt1 ; if so then call increment count1 > > Thanks for your time ! > James Holbrook Hello james, I think the problem is that RA4 is an open collector output, i can see the problem on the PIC 16C63 and several nights of work were necessary to solve the problem. For more information see page 2-743 of the PIC 16/17 microcontroller data book and you will see RA4 is buffer type ST wich is open collector output. Nice work. JEAN-PIERRE