
Originally Posted by
Darrel Taylor
sougata,
I'm glad it's working out for you. And yes, it is more managable. Kinda the whole idea behind it.
Squibcakes,
No, it doesn't work that way.
The AD_INT is fired on the completion of an A/D conversion. Not when the value changes.
So, in your AD_INT handler, you could test to see if the recent A/D reading differs from the previous A/D value. If it does, call a subroutine.
Then start another conversion before exiting the handler.
Added: Or like sougata said, have a timer periodicaly start a conversion, then do the same.
HTH,
I've been using DT_INTS-14 for a while with various types of interrupts but now I want to implement one for A/D. I've created the dummy interrupt handler, but my question is whether I can read the value of the conversion using PBP's ADCIN or should I grab directly from the registers. If the latter, I could use some help with that.
My ADC set up is as follows:
Code:
; PIC12F1840
DEFINE ADC_BITS 8 ; Set number of bits in result
DEFINE ADC_SAMPLEUS 5 ; Set sampling time in uS
DEFINE ADC_CLOCK 3 ; Set clock source (3=rc)
FVRCON = 0 ' Fixed Voltage Reference is disabled
ANSELA = %00000010 ; Analog on PORTA.1 (AN1) only
ADCON0 = %00000101 ' ADC (analog-to-digital) is enabled on AN1 (RA1) only
ADCON1.7 = 0 ; Left-justified results in 8-bits
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler INT_INT, _Flash_Mode_Btn, PBP, yes
INT_Handler AD_INT, _ADC_change, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
' Enable interrupts
@ INT_ENABLE INT_INT ; INT Interrupt
@ INT_ENABLE AD_INT ; A/D Interrupt
I'm working on implementing Darrel's MIBAM with a trim pot to set the brightness of an LED.
Bookmarks