portTest3 (1) - Notepad
File Edit Format View Help
.text
.set noreorder
.globl main
.ent main
// Including xc.h allows use of SFR names, bit masks, etc.
// ... but defines register names without $ in front, annoyingly
#include <xc.h>
main:
sw zero, TRISA
sw zero, ANSELA
li to, _PORTA_RAO_MASK
sw to, LATASET
toggle:
li t1, 0x003FFFFF
delay:
addi t1, t1, -1
bne t1, zero, delay
nop
sw to, LATAINV j toggle
spin:
nop
j spin
nop
.end main
## Text section contains code
## Disable instruction reordering
## Define main label as a global entity
## and an entry point
## TRISA = 0 --> all PORTA bits = output
## ANSELA = 0 --> all PORTA bits digital
## $t0 = 0x00000001
## Set Port A, bit 0 (turn LED1 on)
## Set delay counter
## Toggles LED about every 1.5 seconds
## Decrement counter
## and continue doing that until we hit 0
## Reset delay counter and start again