12.07.2015 Views

Interfacing the M68HC05 MCU to the MC145051 A/D Converter

Interfacing the M68HC05 MCU to the MC145051 A/D Converter

Interfacing the M68HC05 MCU to the MC145051 A/D Converter

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Freescale Semiconduc<strong>to</strong>r, Inc.Application NoteAppendix F — MC68HC705K1/<strong>MC145051</strong> Assembly CodeCS equ 0 ;bit # for chip selectSER_CLK equ 1 ;bit # for serial clockSER_OUT equ 2 ;bit # for serial data outSER_IN equ 3 ;bit # for serial data in*** RAM s<strong>to</strong>rage variables ***nc...Freescale Semiconduc<strong>to</strong>r, Iorg $E0 ;start of static RAMRESULT rmb 2 ;2 bytes needed for 10 bit resultCHANNEL rmb 1 ;a/d channel #TMP_CHN rmb 1 ;temp a/d channel for routine*** Start of program ***org $200 ;start of user eprom*** Initialization *START lda #$01 ;init port Asta PORTAlda #$07 ;init i/o of port Asta DDRA*** Init CS <strong>to</strong> low <strong>to</strong> start a/dbclr CS,PORTA ;CS* line is lowlda CHANNEL ;load ACCA with a/d channel #;(for emulation, init $E2=$00)sta TMP_CHN ;s<strong>to</strong>re ACCA <strong>to</strong> temp channelclr RESULT+1 ;clear result regsclr RESULTldx #4T ;init counter for LOOP1*** Read <strong>the</strong> serial input pinLOOP1 brclr SER_IN,PORTA,L1_1 ;carry bit = serial inL1_1 rol RESULT+1 ;rotate left resultrol RESULT*** Write <strong>the</strong> serial output pinrol TMP_CHN ;rotate left TMP_CHNbrclr 4,TMP_CHN,L1_2 ;if tmp_chn bit4 = 0, go<strong>to</strong> L1_2bset SER_OUT,PORTA ;ser_out = 1bra L1_3 ;go<strong>to</strong> L1_3L1_2 bclr SER_OUT,PORTA ;ser_out = 0AN1228 — Rev. 2.0MOTOROLA 29For More Information On This Product,Go <strong>to</strong>: www.freescale.com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!