beautypg.com

Texas Instruments TLV1562 User Manual

Page 62

background image

Software Overview

56

SLAA040

* use calibrated mode in the following for conversion

@CR0_SEND |= #CALIB_OP ; set calibration for further use

* clear mode related bits in CR_CALIBRA and set MONO_INT:

@CR_CALIBRA &= #(MONO_INT^0FFFFh) ; clear bit for no calibration use

@CR_CALIBRA &= #(DUAL_INT^0FFFFh) ; clear bit for no calibration use

@CR_CALIBRA &= #(MONO_CONTINUOUS^0FFFFh); clear bit for no calibration use

@CR_CALIBRA &= #(DUAL_CONTINUOUS^0FFFFh); clear bit for no calibration use

@CR_CALIBRA |= #MONO_INT ; set calibration for further use

* clear clock related bits in CR_CALIBRA and set internal clock mode:

@CR_CALIBRA &= #(CLK_INTERNAL^0FFFFh) ; clear bit for no calibration use

@CR_CALIBRA &= #(CLK_EXTERNAL^0FFFFh) ; clear bit for no calibration use

@CR_CALIBRA |= #CLK_INTERNAL ; set calibration for further use

* set mode for intermal offset calibration:

@CR_CALIBRA |= #SYS_OFF_CALIB ; set internal calibration mode

*******************************

* verify ADC register CR0/CR1

*******************************

* write CR1 (to reset old CSTART mode initialization, because otherwise, the ADC never sets

* back its INT– pin to show a sample is available:

@CR_PROBLEM = #(SW_PWDN|NO_AUTO_PWDN|NO_2COMPLEMENT|NO_DEBUG|RES_10_BIT|RD_CONV_START);

port(ADC) = @CR_PROBLEM ; Address decoder sets CS low,

; WR low and send CR_PROBLEM value to the ADC

NOP ; wait for tW(CSH)=50ns

* write CR1

* initialize the send values to setup the two programmable registers of the ADC

@CR_PROBLEM =
#(NO_SW_PWDN|NO_AUTO_PWDN|NO_2COMPLEMENT|NO_DEBUG|RES_10_BIT|CST_CONV_START);

port(ADC) = @CR_PROBLEM ; send CR0 value to the ADC

port(DEACTIVE) = @ZERO ; deselect ADC (CS high)

NOP ; wait for tW(CSH)=50ns

* write CR0

port(ADC) = @CR_CALIBRA ; send CR0 value to the ADC

port(DEACTIVE) = @ZERO ; deselect ADC (CS high)

NOP ; wait for tW(CSH)=50ns

********************************************

* do one sample to perform the calibration

********************************************

XF = 0 ; clear CSTART

repeat(#10)