What issues should be paid attention to when writing PIC microcontroller source program?[Copy link]
When writing the source program of the PIC microcontroller, in addition to the strict list instructions at the beginning of the source program, you must also pay attention to the rules of upper and lower case letters in the source program, otherwise it will not be successful when assembling the source program on the PC. The author uses the following source program of the PIC16F84 microcontroller sending numbers to port B (the source program is defined separately) as an example to illustrate the issues that need to be paid attention to. LIST P=PIC16F84 #INCLUDE P16F84?INC ORG 0 START CLRW ; starting address BSF STATUS, 5 ; select body 1 MOVWF TRISB ; set port B to output BCF STATUS, 5; reset STATUS, 5 MOVW 0xAA ; the LED of port B can be turned on MOVWF PORTB ; port B outputs 10 101010 LOOP GOTO LOOP END In the above source program, the pseudo-instruction INCLUDE is used, which means reading the PIC16F84 file specified by the list (in MPLAB) into the source program as part of the above source program. Therefore, all the registers related to the PIC16F84 microcontroller in MPLAB do not need to be assigned using the assignment instruction (EQU) in the above source program, which greatly simplifies the established source program.
In addition, due to the pseudo-instruction INCLUDE, according to the format in MPLAB software, the operands in the source program that involve the register names specified by MPLAB can only be capitalized, not lowercase. The rest of the opcodes and labels can be any uppercase or lowercase, but the x in 0x should be lowercase, otherwise the assembly will not succeed. In view of the above reasons, for the convenience of writing, when using MPLAB software, it is advisable to use uppercase letters in the source program of the PIC microcontroller (except 0x).