Reply to the code you have messaged:
First of all when the code is being explained here do refer with the data sheet of the concerned PIC you are using & i would prefer 16F877A.
list p=16f876a ; list directive to define processor
#include <p16f876a.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _RC_OSC & _WRT_OFF & _LVP_ON & _CPD_OFF
;************************************************* ******************
This step is given to include the library details of the PIC you are using.It can be 16F877A instead of 876A. The second line is the settings provided to the configuration register in the PIC which is same to all PIC.The _data_ denotes the different bits of the configuration register which is a 16 bit register.
This refers to that the execution of the code starts from the location 0000h location of the internal memory of PIC.
banksel TRISB
movlw 00h
movwf TRISB ;Set all PORTB pins to output
It is done so as to configure PORTB of the PIC as input. Giving the value '0' to the TRIS register of corresponding ports make the port work as output & by giving the value '1' to the TRIS register of corresponding ports make the port work as input.
banksel TRISA
bsf ADCON1,1 ;Port A is digital I/O
bsf ADCON1,2 ;...
movlw 01h
movwf TRISA ;pin 0 is input, the rest is output
This step is provided so as to initialize PORTA channel 1 as DIGITAL channel & the rest of the channel as ANALOG channel(PORTA has ADC functionality).The next step is same as that of PORT initialization.
bsf PORTA,2 ;RS pin on
bsf PORTA,4 ;E pin on
bcf PORTA,3 ;R/W pin off
This step is done so initialize the LCD module whose data pins(D0-D7) are connected to PORTB & command(control) pins are connected to PORTA.(Refer 16*2 LCD module interfacing with PIC).
movlw 41h
movwf PORTB ;"A" character
bcf PORTA,4 ;E pin off
bcf PORTA,2 ;RS pin off
bsf PORTA,3 ;R/W pin on
This part of the code outs the value 'A' out in the LCD via PORTB.The next lines are provided so as to initialize back the LCD module.
This is provided so as to get continues data on the LCD while data is passed via PORTB.
Refer the following links too.This will help you.
https://ww1.microchip.com/downloads/en/devicedoc/39582b.pdf.
Embedded Systems LCD interfacing.
If any doubt still persists post it in the forum.We'll surely help you mate.
Regards,
Jerin.
---------- Post added at 12:23 ---------- Previous post was at 12:22 ----------
Check it out & DO message me........
Regards,
Jerin.