I've looked at a ton of examples for interrupts and indirect addressing modes for PICs and they all seem very confusing for me. I just can't seem to understand it.
So, I'm going to try to make an example, and if you guys could point me in the right direction, I would greatly appreciate it.
Problem:
1) I want to store an array of integers somewhere in memory. Let this list be very simple such as:
2) I want to access the array using a counter.
So, I was wondering if it would be something like this...
Solution:
** - Indicate parts that I am really confused about
if you guys can manage to understand what i am confused about, then god bless you
So, I'm going to try to make an example, and if you guys could point me in the right direction, I would greatly appreciate it.
Problem:
1) I want to store an array of integers somewhere in memory. Let this list be very simple such as:
Rich (BB code):
my_array:
retlw 0x1
retlw 0x2
retlw 0x3
retlw 0x4
So, I was wondering if it would be something like this...
Solution:
** - Indicate parts that I am really confused about
Rich (BB code):
INT_CNT res 1 ; variable for interrupt counter
org 0x1000 ; goto main on start-up
goto main
org 0x1018 ; goto low interrupt service routine
goto low_isr
displayW macro ; displays contents of W onto a 7-segment display
;.....stuff that you dont need to know
endm
main:
bsf INTCON,TMR0IE ; Enable Timer0 Interrupts
bcf INTCON2,TMR0IP ; TMR0 Interrupt Priority = LOW
movlw 0x8F ; Timer0 Config (Timer Mode)
movwf T0CON ; 16-bit, internal clock, 1ms calling intervals
movlw 0x0 ; Initialize INT_CNT to 0
movwf INT_CNT
movlw my_array ; **Want to put address of my_array into FSR0
movwf FSR0
main2
sleep ; Must be woken up from ISR
bra main2
my_array:
retlw 0x1
retlw 0x2
retlw 0x3
retlw 0x4
low_isr:
incf INT_CNT,F ; INT_CNT = INT_CNT + 1
movlw INDF0+INT_CNT ; **Want to access my_array + offset
displayW ; displays contents of W on screen
movlw 0x4 ; If INT_CNT == 4, reset to 0
cpfseq INT_CNT ; Else return
retfie
movlw 0x0
movwf INT_CNT
retfie