FIGnition FUZE Hardware Reference Manual page 61

Table of Contents

Advertisement

The following Forth code provides a simple interface for reading an analog port:
$78 const adData
$7A const adCsrA
$7B const adCsrB
$7C const adMux
$7E const adDidr
$64 const prr
: adInit ( adcRef --)
0 $FE prr >port> drop
adMux ic!
$30 adDidr ic!
$87 adCsrA ic!
;
A simple demonstration program for the sampler follows:
Fig 9.3
 $84 const Tcnt1
50 var sampPeriod! !
!
( in timer1 periods)
clock var sampClock
0 var nextSamp
: sample?
sampClock @ i@
nextSamp @ over - 0<
dup if
sampPeriod @
nextSamp +!
then
; ( sampTime f)
0 var chan
: sample ( chan -- data)
adData i@!
!
!
!
( read sample)
swap adMux ic!!
!
( Select Chan)
$40 0 adCsrA
>port> drop! !
!
( start conversion)
;
!
!
!

Advertisement

Table of Contents
loading

Table of Contents