Re: Multi-Button CSM with Pic16LF722A
the get address macro is part of dt-ints . it places the address of a label in a pbp word var.
this is the actual macro , its already there so why not use it.
Code:
ASM
;---[Returns the Address of a Label as a Word]------------------------------
GetAddress macro Label, Wout
CHK?RP Wout
movlw low Label ; get low byte
movwf Wout
; movlw High Label ; get high byte MPLAB 8.53 killed high
movlw Label >> 8 ; get high byte
movwf Wout + 1
endm
endasm
so
@ GetAddress _my_pwm,_paddress
gets the address of my_pwm: and places it in var paddress
the data
my_pwm:
@ DW 3,6,13,26,50,95,177,328,600,1023 [data stored as an array of 14 bit values]
each flash memory address can hold a maximum 14 bit piece of data
i'm using that address plus an offset to index the array
readcode paddress+pl ,pw ; address + offset
[note pw is a word var]
so if pl= 3
readcode paddress+3, and returns the value 26
hope that's understandable
ps I might add that in my setup that saves 44 words of code space compared to using lookup2
Last edited by richard; - 23rd May 2016 at 12:55.
Reason: ps
Warning I'm not a teacher
Bookmarks