Mike - K8LH
Well-Known Member
Gentlemen,
Would you double check my logic please? I'd like to perform ADC conversions at 20-usec intervals (50-KHz) within an ISR using TMR2 interrupts.
I'm assuming that after setting the GO_DONE bit in the ISR that a conversion will take place and that the next ADC acquistion period will be fullfilled by the time the next 20-usec interrupt occurs.
Will this work?
TIA. Regards, Mike
Would you double check my logic please? I'd like to perform ADC conversions at 20-usec intervals (50-KHz) within an ISR using TMR2 interrupts.
Code:
;
; ADC PWM processing (PWM pulse skipping algorithm)
;
ISR_ADC
bcf PIR1,TMR2IF ; clear TMR2 interrupt flag |B0
movlw DutyCyc ; normal duty cycle value |B0
movwf CCPR1L ; assume VADC < VSET |B0
movf VSET,W ; voltage set point |B0
subwf ADRESH,W ; ADC result hi |B0
skpnc ; VADC < VSET |B0
clrf CCPR1L ; VADC > VSET, skip pulse |B0
bsf ADCON0,GO_DONE ; start next ADC conversion |B0
retfie ; |B0
;
Will this work?
TIA. Regards, Mike
Last edited: