EmbeddedRelated.com
Forums

Analog to Digital Conversions MiniDragon+

Started by lil_dj_6789 May 30, 2006
Hello,

I've been doing a project with the MiniDragon+ Analog to Digital
Converter. I wrote a test program using assembly to see if it works
but it does not. The value I keep getting is $FF. I am sure that my
sensor works since a DMM gives a good reading. What I want to do is
to take in readings from 5 analog sensors continuously so I can
compare values. Here is the program. I have the register include
file and a delay include file. Could someone please help me and tell
me what is wrong? Thanks in advance.

ORG $1000

START LDAA #$80
STAA atd0ctl2
LDAA #$40
STAA atd0ctl3
LDAA #$85
STAA atd0ctl4
LDAA #$B3
STAA atd0ctl5

HERE LDAA atd0stat
BPL HERE
LDAB adr03h+1

SWI

;-------------------------------
#include DELAYS_DRAGON12.INC ;Delays
#include reg9s12.h ;Register Equates
;-------------------------------

The mini dragon should come with a test program
already done. i have the dragon12 board. it has many
examples of programs that can be downloaded into the
evb board. the test program displays on the lcd, seven
segment,leds,piezo buzzer and the ir detector. it uses
all these devices simaltaniously.the mcu is a
mc9s12dp256.
reguards
rob

--- lil_dj_6789 wrote:

> Hello,
>
> I've been doing a project with the MiniDragon+
> Analog to Digital
> Converter. I wrote a test program using assembly to
> see if it works
> but it does not. The value I keep getting is $FF.
> I am sure that my
> sensor works since a DMM gives a good reading. What
> I want to do is
> to take in readings from 5 analog sensors
> continuously so I can
> compare values. Here is the program. I have the
> register include
> file and a delay include file. Could someone please
> help me and tell
> me what is wrong? Thanks in advance.
>
> ORG $1000
>
> START LDAA #$80
> STAA atd0ctl2
> LDAA #$40
> STAA atd0ctl3
> LDAA #$85
> STAA atd0ctl4
> LDAA #$B3
> STAA atd0ctl5
>
> HERE LDAA atd0stat
> BPL HERE
> LDAB adr03h+1
>
>
> SWI
>
>
;-------------------------------
> #include DELAYS_DRAGON12.INC ;Delays
> #include reg9s12.h ;Register Equates
>
;-------------------------------
>
__________________________________________________

I also have a Dragon12 board and code that shows the digital number of
the orange pot onb the LEDs. I tried modifying that code to work with
my sensor but it always reads $FF. Also, does the input have to go up
to 5 V? My sensor readings go up to a max of 2.7 V. Thanks.

--- In 6..., rob vermillion wrote:
>
> The mini dragon should come with a test program
> already done. i have the dragon12 board. it has many
> examples of programs that can be downloaded into the
> evb board. the test program displays on the lcd, seven
> segment,leds,piezo buzzer and the ir detector. it uses
> all these devices simaltaniously.the mcu is a
> mc9s12dp256.
> reguards
> rob
>
> --- lil_dj_6789 wrote:
>
> > Hello,
> >
> > I've been doing a project with the MiniDragon+
> > Analog to Digital
> > Converter. I wrote a test program using assembly to
> > see if it works
> > but it does not. The value I keep getting is $FF.
> > I am sure that my
> > sensor works since a DMM gives a good reading. What
> > I want to do is
> > to take in readings from 5 analog sensors
> > continuously so I can
> > compare values. Here is the program. I have the
> > register include
> > file and a delay include file. Could someone please
> > help me and tell
> > me what is wrong? Thanks in advance.
> >
> > ORG $1000
> >
> > START LDAA #$80
> > STAA atd0ctl2
> > LDAA #$40
> > STAA atd0ctl3
> > LDAA #$85
> > STAA atd0ctl4
> > LDAA #$B3
> > STAA atd0ctl5
> >
> > HERE LDAA atd0stat
> > BPL HERE
> > LDAB adr03h+1
> >
> >
> > SWI
> >
> >
> ;-------------------------------
> > #include DELAYS_DRAGON12.INC ;Delays
> > #include reg9s12.h ;Register Equates
> >
> ;-------------------------------
> >
> >
> >
> >
> >
> __________________________________________________

--- In 6..., "lil_dj_6789" wrote:
> > > ORG $1000
> > >
> > > START LDAA #$80
> > > STAA atd0ctl2
> > > LDAA #$40
> > > STAA atd0ctl3
> > > LDAA #$85
> > > STAA atd0ctl4
> > > LDAA #$B3
> > > STAA atd0ctl5
> > >
> > > HERE LDAA atd0stat
> > > BPL HERE
> > > LDAB adr03h+1
> > >
> > >
> > > SWI

I don't see that you are allowing the AD to stabilize after enabling
it. Spec says wait at least 20 uS for "Recovery Time". That's pretty
long for a 24 MHz bus speed (480 cycles).

FWIW to find cycles I simply calculate (20 * 24). It's easy to enter
because the micro (u) cancels the Mega (M).