AN1154 STMicroelectronics, AN1154 Datasheet - Page 66

no-image

AN1154

Manufacturer Part Number
AN1154
Description
8031-PSD DESIGN TUTORIAL
Manufacturer
STMicroelectronics
Datasheet
AN1154 - APPLICATION NOTE
//There is only one output on Port D (RTCcs/), so the direction register is
//setup as follows:
write(Port_D_Dir_Reg,’h04);
//Set up the mask registers so that only the desired portion of the OMCs get
//written. Only the desired value (MCELLAB[7:4]), and begin (MCELLBC7) can be
//written to.
write(Port_AB_OMC_Mask, ’h0f);
write(Port_BC_OMC_Mask, ’h7f);
//Write the EEPROM segment ees0, and the Flash segment fs1
//then read the SRAM
write(’h0020,’h5a);//write 5a to ees0
write(’h5A00,’ha5);//write a5 to fs1
read (’h07FE); //read the internal SRAM
// Wait, then initialize the gain to one and output the data on the pins
// pb2 to pb0.
#40 write(Port_B_Dout_Reg,’h01);
// Assume a small value for the output of the ADC since the gain is set
// to one
measured_value=’h3;
// Load 5 into the desired value register
write(Port_AB_OMC, ’h50);
// Take the state machine out of the idle state and generate the ADC
// chip select.
#20 write(Port_BC_OMC, ’h80);
// Since the measured value is less than the desired one, the gain would
// be boosted after the interrupt was generated (3 cycles after the start
// of the state machine). The MCU should increment the gain by 1 at that
// time.
#400 write(Port_B_Dout_Reg, ’h02);
#10 $finish;
66/83

Related parts for AN1154