mylim

HCS08 bit bang on 16-bit DAC register

Discussion created by mylim on Sep 21, 2009
Latest reply on Sep 22, 2009 by bigmac

Hi guys,

I'm using QE128 bit bang to a Analog Device's DAC AD5308 which it has a 16-bit register instead of 8-bit. So I guess I can't use the i2c peripheral.

I've managed to write an assembler code for this application. However, I'd like to enhance my code efficiency which I think my code isn't that efficient.

 

 


DACDTA     ds.B 2
DACBUF     ds.B 1
DTACNT     ds.B 1

txdac       sthx  DACDTA           ;load data to DACDTA
            lda   DACDTA+1         ;load hi-byte
            sta   DACBUF
            lda   #$00
            sta   SR
txdacnxt    lda   #$07             ;setup data count
            sta   DTACNT
            bclr  SYNCDAC,PTBD     ;clr SYNC to start tx
txdac0      bclr  SCLDAC,PTAD      ;pulse clk
            jsr   TDelay
          
            bset  SCLDAC,PTAD
            lda   DACBUF           ;load data to acc
            asla                   ;left shift acc
            bcs   txdac1           ;chk if carry = 1
            bclr  SDADAC,PTAD      ;if /=1,clr SDA
            bra   txdac2
txdac1      bset  SDADAC,PTAD      ;if =1,set SDA
txdac2      jsr   TDelay
            dbnz  DTACNT,txdac0    ;dec data count to chk byte tx
          
txdac3      brset 0,SR,txdac4      ;chk if hi-byte done tx
            bset  0,SR
            lda   DACDTA+0         ;load lo-byte
            sta   DACBUF
            bra   txdacnxt         ;repeat tx
txdac4      bset  SYNCDAC,PTBD     ;clr SYNC to end tx
            rts                  

 

 Please advise.
Thanks.
 
Regards,
MY 

 

 

Message Edited by mingyee on 2009-09-21 04:50 PM
Message Edited by t.dowe on 2009-09-21 08:56 AM

Outcomes