Hello,
I'm using AD7730 in weigh scale applications,here is example codes of writing and reading of registers:
ADdata var word 'variable to hold 16 bit result.
DATAin con 2 'AD data input pin.
DATAout con 3 'AD data output pin.
SCKL con 4 'clock to AD.
RDY con 5 'RDY input .
input 5
Initial:
SHIFTOUT DATAin,SCLK,MSBFIRST,[noparse][[/noparse]$FFFF\16,$FFFF\16] 'write 32 ones will reset the AD7730 to the default state.
SHIFTOUT DATAin,SCLK,MSBFIRST,[noparse][[/noparse]$02] 'write to communication register setting next operation as write to mode register.
SHIFTOUT DATAin,SCLK,MSBFIRST,[noparse][[/noparse]$3080\16] 'write to mode register starting continuous conversion for 10mV input range,unipolar,16 bit data word and 5V reference.
SHIFTOUT DATAin,SCLK,MSBFIRST,[noparse][[/noparse]$21] 'write to communication register setting next operation as continuous read from data register.
low 2 ' set DIN line low to insure part is not reset while in continuous reade mode.
ReadData:
waitRDY:
IF RDY = 1 THEN waitRDY 'wait for RDY to go low to indicate output update.
SHIFTIN DATAout,SCLK,MSBPOST,[noparse][[/noparse]ADdata\16] 'read conversion result from data register.
Comments
I'm using AD7730 in weigh scale applications,here is example codes of writing and reading of registers:
ADdata var word 'variable to hold 16 bit result.
DATAin con 2 'AD data input pin.
DATAout con 3 'AD data output pin.
SCKL con 4 'clock to AD.
RDY con 5 'RDY input .
input 5
Initial:
SHIFTOUT DATAin,SCLK,MSBFIRST,[noparse][[/noparse]$FFFF\16,$FFFF\16] 'write 32 ones will reset the AD7730 to the default state.
SHIFTOUT DATAin,SCLK,MSBFIRST,[noparse][[/noparse]$02] 'write to communication register setting next operation as write to mode register.
SHIFTOUT DATAin,SCLK,MSBFIRST,[noparse][[/noparse]$3080\16] 'write to mode register starting continuous conversion for 10mV input range,unipolar,16 bit data word and 5V reference.
SHIFTOUT DATAin,SCLK,MSBFIRST,[noparse][[/noparse]$21] 'write to communication register setting next operation as continuous read from data register.
low 2 ' set DIN line low to insure part is not reset while in continuous reade mode.
ReadData:
waitRDY:
IF RDY = 1 THEN waitRDY 'wait for RDY to go low to indicate output update.
SHIFTIN DATAout,SCLK,MSBPOST,[noparse][[/noparse]ADdata\16] 'read conversion result from data register.
DEBUG DEC ADdata,cr 'display data in decimal.
pause 500 'wait 0.5 second between reading.
GOTO ReadData
Regards
Mohamed Refky