In this post, I want to share how to write a program in assembler to get started with PIC18F2550 and MPLAB X.
The program can be segmented into 3 parts. The First part is PIC selection through the list and include reserved words.
The second part of the program is the bit configurations.
Finally, the 3rd part of the program is the application program. In this sample, I only get a toggle in the PORT RC0.
Enjoy your first program and please remember that I can teach you or help you with your projects, you can contact me at:
postgraduatecahg@gmail.com
list p=18f2550
include "P18F2550.INC"
CONFIG FOSC = HS ;HS crystal oscilator 8MHz
CONFIG MCLRE = ON ; enable Master Clear
CONFIG BOR = OFF ;Brown-out OFF
CONFIG PWRT = OFF; Power-up Timer OFF
CONFIG LVP = OFF ;Low-Voltage programming disabled (necessary for debugging)
CONFIG WDT = OFF ;disable watchdog timer
CONFIG PBADEN = OFF ;This is to confing ADC converter check the datasheet
CONFIG CP0 = OFF ;No code protection
CONFIG CP1 = OFF;
CONFIG CP2 = OFF;
CONFIG CP3 = OFF;
CONFIG CPB = OFF;
CONFIG CPD = OFF;
ORG 0x00
GOTO START
ORG 0x50
START
CLRF PORTC ; Clear PORTC.
CLRF TRISC ; PORTC is confired as outputs.
MAIN
BTG PORTC, RC0 ; RC0 Bit toggle.
GOTO MAIN ; Goto to main address.
END
For further information about the bit configuration, you can search in the datasheet and in the next link.
https://openlabpro.com/guide/configuration-bits-for-pic18f4550/
No hay comentarios.:
Publicar un comentario