I am trying to use PORTA of PIC16F877A as digital output port. But somehow it does not seems to be working.
I am using MPLAB X IDE MPASM to assemble the code. Below is the code I am using to initialize PORTA –
banksel PORTA;
clrf PORTA;
banksel ADCON1
movlw 0x06
movwf ADCON1
banksel CMCON
movlw 0x07
movwf CMCON
banksel TRISA
movlw 0x00
movwf TRISA
banksel PORTA
movlw 0xFF
movwf PORTA
The LEDs at the output does not glow at all. What am I missing? I am not expecting RA4 to glow as I know it requires an external pull-up resistor but what about other LEDs.
Any help would be much appreciated. Thanks in advance.
Best Answer
It looks like this code, such as it is, is setting up the digital outputs correctly. It is good that you used BANKSEL to eliminate any issue of possibly bad bank setting. However, this code still has some serious problems:
To test the pin setup by itself, disconnect the LEDs and just look at what the pins are doing with a scope. There is a good chance your problem is with the circuit. Show the complete circuit.