English
Language : 

AN113 Datasheet, PDF (44/52 Pages) Silicon Laboratories – SERIAL COMMUNICATION WITH THE SMBUS
AN113
check_1 = SLA_READ(CHIP_B, (0x40 | READ_BUF));
check_1 = SLA_READ(CHIP_B, (0x60 | READ_BUF));
check_1 = SLA_READ(CHIP_B, (0x80 | READ_BUF));
check_1 = SLA_READ(CHIP_B, (0x10 | READ_BUF));
// Read index 4 from the buffer
// Read index 6
// Read index 8
// Read index 1
// Loop to continuously increase the DAC output on CHIP_B, and read its
// ADC each round. DAC output on CHIP_B should ramp.
for (i=0;i<50;i++){
SLA_SEND(CHIP_B, WRITE_DAC, 2*i);
check_1 = SLA_READ(CHIP_B, READ_ADC);
check_2 = 2*i;
}
// Write 2*i to DAC0 on CHIP_B
// Read AIN0 on CHIP_B
// check_1 should be approximately
// the same as check_2.
// END TEST CODE----------------------------------------------------------------------
}
//------------------------------------------------------------------------------------
// Initialization Routines
//------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// SYSCLK_Init
//-----------------------------------------------------------------------------
//
// This routine initializes the system clock to use an 22.1184MHz crystal
// as its clock source.
//
void SYSCLK_Init (void)
{
int i;
// delay counter
OSCXCN = 0x67;
// start external oscillator with
// 22.1184MHz crystal
for (i=0; i < 256; i++) ;
// XTLVLD blanking interval (>1ms)
while (!(OSCXCN & 0x80)) ;
// Wait for crystal osc. to settle
OSCICN = 0x88;
}
// select external oscillator as SYSCLK
// source and enable missing clock
// detector
//------------------------------------------------------------------------------------
// Functions
//------------------------------------------------------------------------------------
// Send to slave.
// The send function transmits two bytes to the slave device: an op code, and a data
// byte. There are two op code choices for sending data: WRITE_DAC and WRITE_BUF.
// If the op code is WRITE_BUF, then the upper 4 bits of the op code should contain
// the buffer index. For example, to write to index 2 of the data buffer, the
// op_code parameter should be (0x20 | WRITE_BUF).
//
// chip_select = address of slave device.
44
Rev. 1.3