Using ADC in QG8 with Assembly Step in CW Debugger

Discussion created by Guest on Feb 5, 2008
Latest reply on Feb 5, 2008 by Guest
I have written a short code for Assembly Step to test my QG8 circuit, when I use Assembly Step within MainLoop: loading the EQU values and stores to Port B it display correctly.

However, I would like to display the sampled data in ADCRL continuosly i.e varying the input voltage at ADCH 0 and display it on the LEDs. When I step the code within MainLoop: the value displays on the LEDs does not change, can anyone have a look at my code and suggest why the value loaded from ADCH0 remains unchanged?


; application entry point
            ABSENTRY _Startup

; export symbols
            XDEF _Startup
            ; we use '_Startup' as an export symbol. This allows
            ; us to reference '_Startup' either in the linker
            ; *.prm file or from C/C++ later on.
            ; Include derivative-specific definitions
            INCLUDE ''

;*      data section        *

                ORG   $F500       
ZERO            equ   $C0               ; 7 segment LED digit
ONE             equ   $F9
TWO             equ   $a4
THREE           equ   $B0
FOUR            equ   $99
FIVE            equ   $92
SIX             equ   $82
SEVEN           equ   $78
EIGHT           equ   $80
NINE            equ   $18
DOT             equ   $EF

;Latch select 7 segment led digit

Digit           equ   $08
Deci            equ   $04
Sec_Deci        equ   $02

;*   program variables       *

ADCSample       DS.B   1


            ORG    ROMStart


;_Initialize Set up:

            LDHX   #RAMEnd+1           ; initialize the stack pointer

;//======== ADC SETUP ==========//

            lda   #%00001011           ; high pwr | /1 | short sampling | 10 bit | Asynchronous clock (ADACK)
            sta   ADCCFG
            lda   #%00100000           ; interrupt disabled | Continuous Conversion | ADCH 0 |
            sta   ADCSC1               ;
            lda   #%00100000           ; Software trigger | Compare function enabled | Compare triggers when input is less than compare level |      
            sta   ADCSC2               ;
            lda   #%00000001           ; disable the I/O port
            sta   APCTL1               ; used as analog inputs.

;//========PORT SETUP===========//

            lda   #%00001110           ; set pin PA1 PA2 PA3 output
            sta   PTADD
            lda   #%11111111           ; set port B as output                  
            sta   PTBDD             

;         ******************      
;**********                **********
;*//======{  PROGRAM MAIN  }======//*
;**********                **********
;         ******************

            lda   #Sec_Deci            ;select 2nd decimal(7 segment LED)
            sta   PTAD
            lda   ADCRL                ;load low byte sample
            sta   PTBD                 ;display low byte
            lda   #Deci                ;select 1st decimal(7 segment LED)          
            sta   PTAD
            lda   ADCRL
            sta   PTBD
            lda   #Digit               ;select digit(7 segment LED)          
            sta   PTAD
            lda   ADCRL
            sta   PTBD
            bra   MainLoop

            org   Vreset
            dc.w  _Startup



Message Edited by Learner on 2008-02-05 06:03 AM

Message Edited by Learner on 2008-02-05 06:12 AM