PDA

View Full Version : How to put data into arrays under assembler interrupt ?



Chris Barron
- 26th March 2009, 12:10
Hello.
I have a question which probably (hopefully) has a simple solution but I'm out of ideas.

PIC = 18f87j10, 10MHz.

An assembly interrupt is being triggered by the reception of a data byte, and I want to put that byte into an array. The array is the 5th 'variable' in my declaration

W_TEMP var byte system ; interupt context save registers
BSR_TEMP VAR BYTE system
STATUS_TEMP var byte system
RX_BUF var byte ; Buffer for storing the incoming data from USARTS

RX_message var byte[127]; buffer to store received USART messages


I have tried
movlw HIGH(array_name)
movwf FSR0H
movlw LOW(array_name)
(add array offset)
movwf FSR0L

...and then putting the RX'd byte into INDF0

movff RX-byte, INDF0

It seemed to work for a while, but then I changed the size of my array from 20 bytes to 127 bytes. I guess I am crossing a boundary or is it something else ?

Should I try using Table write instead ?

Chris

(I can't do away with the assembler interrupt because I am running ethernet (Lantronix XPORT - tftp) on one USART, Zigbee wireless on the other USART, and an SD card on the SPI. I have checked for conflicts by removing the sd card code and variables)

Archangel
- 26th March 2009, 16:20
Hi Chris,Dunno if this is what you want . . check the code in post 16, this uses Darrel's instant interrupts. http://www.picbasic.co.uk/forum/showthread.php?t=4972

Chris Barron
- 26th March 2009, 16:29
Hi Chris,Dunno if this is what you want . . check the code in post 16, this uses Darrel's instant interrupts. http://www.picbasic.co.uk/forum/showthread.php?t=4972

Thanks, you beat me to it because I was about to post to say that I have created an interrupt 'alias' by setting flags in the interrupt and then processing them once control has been restored to the main program. This has meant that I can just stick with using the usual picbasic method of dealing with arrays throughout( and I can leave the rest for another day ;-) )