Here's a quick untested stab at an ASM handler.
Change the Handler type to ASM
Code:
Samples VAR BYTE[15] BANK0 SYSTEM
SamplePTR VAR BYTE BANK0 SYSTEM
SamplesAddr CON EXT
@SamplesAddr = Samples
BitCount VAR BYTE BANK0 SYSTEM
ByteCount VAR BYTE BANK0 SYSTEM
FlagSample VAR BIT
TMR2ON VAR T2CON.2
;----[Start getting the 120 samples]------------------------------------------
GetSamples:
FlagSample = 0
SamplePTR = SamplesAddr
ByteCount = 15
BitCount = 8
PR2 = 125 : TMR2 = 0 : TMR2ON = 1
return
;----[TMR2 Handler]-----------------------------------------------------------
ASM
Sample
MOVE?BB SamplePTR, FSR ; Load FSR with pointer to array
MOVE?TT CMCON,7, STATUS,C ; Put sample in carry flag
rrf INDF, F ; Shift in the sample bit
decfsz BitCount, F ; Are all 8 bits in ?
goto Int_Done ; NO, done for now
MOVE?CB 8, BitCount ; Yes, reset bitcount
incf SamplePTR, F ; Point to next byte
decfsz ByteCount, F ; Are all 15 bytes done ?
goto Int_Done ; NO, done for now
MOVE?CT 1, _FlagSample ; Yes, Indicate - Samples Complete
MOVE?CT 0, _TMR2ON ; stop the timer
Int_Done
INT_RETURN
ENDASM
Bookmarks