![]() | ||
| Home | SwiftX Archive | SwiftForth Archive | |

Hi,
I am working with the ATmega128 and am trying to do
A/D conversion. It seems to be enough simple and
the code below should do it.
THe problem I have is I can't set bit 6 of the
ADCSR (ADSC bit).
Did some of you encountered the same problem?
Thanks in advance for any useful info you can provide.
Viviane Beullens
\ Code
TARGET
|U| |S| |R| BACKGROUND SCRIBE
VARIABLE RESULT
\ Select in ADMUX inputpin 0 in PORTF
: selectMUX0
ADMUX c@ 1 OR ADMUX C! ;
\ Request a conversion setting ADSC bit in ADCSR, bit 6
: SetADSC ADCSR C@ 64 OR ADCSR C! ;
\ Set enable bit in ADCSR, ADEN, bit 7
: SetADEN
ADCSR C@ 128 OR ADCSR C! ;
\ Disable ADEN
: DISABLEADEN
ADCSR C@ 127 AND ADCSR C! ;
\ Read result when ADIF is high
: READRES ( f -- )
ADCL C@ RESULT 1+ C! ADCH C@ RESULT C! ;
\ Do conversion until ADIF bit is set
: DoA/D
BEGIN
selectMUX0 SetADSC SetADEN
ADCSR C@ 16 AND
UNTIL
READRES
DISABLEADEN RESULT @ . ;
: SCRIBEACT SCRIBE ACTIVATE BEGIN PAUSE DOA/D AGAIN ;
: /SCRIBE 0 RESULT ! SCRIBE BUILD ;
----------------------------------------------------------------------
swiftx_at_forth.com The SwiftX programming discussion email list
To unsubscribe, send subject "unsubscribe" to swiftx-request_at_forth.com
For list command help, send subject "help" to swiftx-request_at_forth.com
Message archives are located at http://www.forth.com/archive/swiftx
----------------------------------------------------------------------
This list is a forum for SwiftX users. For product support and bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Tue Sep 02 2003 - 09:51:01 PDT
This archive was generated by hypermail 2.2.0 : Mon Dec 01 2008 - 03:04:48 PST