AnsweredAssumed Answered

Hcs08 AD converting problem

Question asked by Tomas Micovcin on Dec 13, 2010
Latest reply on Dec 14, 2010 by Tomas Micovcin

Hello Im using demoboard mc9S08LC60. and i want convert value from potentiometer.

My code is in assembler, but evry registers are set like in demo code write in C .

 

Problem is that there is no results from AD converting .  - i thing that converting is not start.

here is my code. Thanks.

;*******************************************************************
;* This stationery serves as the framework for a user application. *
;* For a more comprehensive program that demonstrates the more *
;* advanced functionality of this processor, please see the *
;* demonstration applications, located in the examples *
;* subdirectory of the "Freescale CodeWarrior for HC08" program *
;* directory. *
;*******************************************************************

; Include derivative-specific definitions
INCLUDE 'derivative.inc'

; export symbols
XDEF _Startup, main
XDEF tlacidlo_ISR, main
XDEF prevod_ISR, main
; XDEF hodiny,main
; we export both '_Startup' and 'main' as symbols. Either can
; be referenced in the linker .prm file or from C/C++ later on


XREF __SEG_END_SSTACK ; symbol defined by the linker for the end of the stack


; variable/data section
MY_ZEROPAGE: SECTION SHORT ; Insert here your data definition

; code section
MyCode: SECTION


; zacoatok hlavneho programu
main:
_Startup:
; inicializacia
LDHX #__SEG_END_SSTACK ; initialize the stack pointer
TXS
CLI

LDA #$13
STA SOPT1 ; enable interrupts
; port B3-7 and port A as output
LDA #$F8
STA PTBDD

LDA #$E0
STA PTADD


; set clock FEI

Hodiny:

LDA $FFBE
STA $3E

LDA #$28
STA ICGC1

LDA #$51
STA ICGC2
BRCLR 3,ICGS1,Hodiny


; Counter overflow every 1ms
LDA #$1F
STA TPM1MODH
LDA #$40
STA TPM1MODL
; Stops timer and selects 1 as prescaler divisor
LDA #$08
STA TPM1SC

; set ad convertor
LDA #$20 ; 22 pta2 to je x os
STA ADCSC1 ; nastavenie adc prevodnika
LDA #$60 ;60
STA ADCCFG ;mo, bez clock divide, short sample, 8 bit , bus clock
LDA #$00
STA ADCSC2


mainLoop:
; Insert your code here


prevod: BRCLR 7,ADCSC1,prevod
LDA $13

feed_watchdog
BRA mainLoop













Outcomes