;
; adc.inc: a/d conversion routines for
; tempo potentiometer sampling
;
; note: a/d converter is initialized in
; startupinit.inc
;
; note: no acquisition delays are required
; as the conversion is synchronized
; with timer 2
;
; author: Marko Kanala, raato ]a t[ mulletronic.com
;
; LICENSE
; Creative Commons Attribution-NonCommercial-ShareALike 2.5
;
; You are free:
;
; * to copy, distribute, display, and perform the work
; * to make derivative works
;
; Under the following conditions:
;
; 1. Attribution. You must attribute the work in the manner specified by the
; author or licensor.
; 2. Noncommercial. You may not use this work for commercial purposes.
; 3. Share Alike. If you alter, transform, or build upon this work, you may
; distribute the resulting work only under a license identical to this one.
;
; * For any reuse or distribution, you must make clear to others the license
; terms of this work.
; * Any of these conditions can be waived if you get permission from the
; copyright holder.
;
; Your fair use and other rights are in no way affected by the above.
;
; This is a human-readable summary of the Legal Code.
; See full license at http://creativecommons.org/licenses/by-nc-sa/2.5/legalcode
;
; Copyright: Marko Kanala (raato@mulletronic.com).
;
; (re)starts the a/d conversion
ad_start:
movlw do_ad_every_timer2
movwf ad_delay
bsf ADCON0, GO
return
; called on a/d converter interrupt
; occurred - reads the current value
; and assigns the tempo with the value
ad_irq:
movf ADRESH, W ; read a/d value
; set tempo
; 0 == 30 bpm
; 255 == 285 bpm
cpfseq tempo ; tempo changed ?
bra ad_tempo_changed
return
ad_tempo_changed:
movwf tempo
SETEVENT EVENT_TEMPOCHANGE
return
;
; called on timer2 interrupt
; see irq_lopri.inc
;
ad_timer2:
decfsz ad_delay
return
call ad_start
return
External Labels :
ad_start