I am having a hard time understanding a problem with PORTA on a PIC16F874.
What I am wanting do is flash an LED on RA0. I order to tell if it is on or of, so I know to bsf or bcf RA0, I do a btfsc PORTA, 0 , it is always true, RA0 clear. However, if I leave the code the same EXCEPT use PORTB, everything works and LED flashes. Here is the code:
bsf STATUS,RP0
movlw 0x00
movwf TRISA
bcf STATUS, RP0
;this code is an interrupt service routine, toggles the LED every time it is enterd
btfsc PORTA, 0
goto LEDoff
bsf PORTA, 0
bsf led_state, 0
goto leave
LEDoff:
bcf PORTA, 0
bcf led_state, 0
leave:
Like I said, if you change port to PORTB and TRISB, it works fine
tj
What I am wanting do is flash an LED on RA0. I order to tell if it is on or of, so I know to bsf or bcf RA0, I do a btfsc PORTA, 0 , it is always true, RA0 clear. However, if I leave the code the same EXCEPT use PORTB, everything works and LED flashes. Here is the code:
bsf STATUS,RP0
movlw 0x00
movwf TRISA
bcf STATUS, RP0
;this code is an interrupt service routine, toggles the LED every time it is enterd
btfsc PORTA, 0
goto LEDoff
bsf PORTA, 0
bsf led_state, 0
goto leave
LEDoff:
bcf PORTA, 0
bcf led_state, 0
leave:
Like I said, if you change port to PORTB and TRISB, it works fine
tj