To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.handyboardOpen lugnet.robotics.handyboard in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / Handy Board / 4564
4563  |  4565
Subject: 
RE: Read A/D converter
Newsgroups: 
lugnet.robotics.handyboard
Date: 
Thu, 22 Oct 1998 14:21:26 GMT
Original-From: 
Kevin B. Smith <kbsmith@eeSTOPSPAMMERS.byu.edu>
Viewed: 
1631 times
  
I didn't look that closely at your program but I have included a routine to
read the analog ports that I know works.

After assembling and loading the program, you make two c function calls:
powerup_ad(); and read_ad(i); where i is the analog port address you want to
read.

Best wishes,

Kevin Smith

Assistant Professor
Brigham Young University

*****  Read_ad.asm *****************

BASE EQU $1000
ADCTL  EQU $30
ADR4   EQU $34
OPTION EQU $39

ORG MAIN_START

subroutine_powerup_ad:
    PSHX ;Preserve IX
LDX #BASE ;Points to register
BSET OPTION,X $80 ;ADPU = 1 to power up.
BCLR OPTION,X $40 ;CSEL = 0 to select E clock.
* ;need to wait for 100 us for
*                        A/D to warm up (but not done here).
PULX ;restore IX
RTS

subroutine_read_ad:
* ;Analog port should be in ACCB.
    SEI ;Turn off System interrupts
    PSHX ;Preserve IX
LDX #BASE ;Points to register
ANDB #%00000111 ;Set SCAN =0 & MULI = 0, ANx in low 3 bits(CC CB CA).
STAB ADCTL,X ;Store port select value
BRCLR ADCTL,X $80 * ;Wait for conversion to finish (i.e. CCF = 1)
LDAB ADR4,X          ;Load result
CLRA
CLI ;Enable other interrupts
PULX ;restore IX
RTS



-----Original Message-----
From: HECTOR NORIEGA [mailto:110060.2126@compuserve.com]
Sent: Thursday, October 22, 1998 12:08 AM
To: Handyboard
Subject: Read A/D converter

"HI" , I am trying to read the A/D converter but the program gets "Hung-Up"
on the line ...



Message is in Reply To:
  Read A/D converter
 
"HI" , I am trying to read the A/D converter but the program gets "Hung-Up" on the line "ANALOOP", the CCF bit never sets. Please give me a hint. Here is the Assembly code. /* MAGLEV.ASM, Magnetic Levitation by Hector Noriega, 28JUNE1998.*/ /*Handy (...) (26 years ago, 22-Oct-98, to lugnet.robotics.handyboard)

2 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR