//APPLIC37 analog C51 sample routines
//
//DAC1 routine outputs the DAC_VALUE contents to the DAC channel 1
//DAC2 routine outputs the DAC_VALUE contents to the DAC channel 2
//ADC routine reads one of the analog channels (according to the ADC_CHANNEL
contents and returns the value in the ADC_VALUE
// Hardware Handling
sbit
at
0x90
sbit
at
0x91
sbit
at
0x92
sbit
at
0x93
sbit
at
0x94
unsigned char DAC_VALUE;
unsigned char ADC_CHANNEL;
unsigned char ADC_VALUE;
char B;
sdac(char A)
{
char J;
for (J = 1; J < 9; J++)
{
if ((A & 0x80) == 0x80)
{
ser_di = 1;
}
else
{
ser_di = 0;
}
ser_clk = 1;
ser_clk = 0;
A = A<<1;
}
dac1()
{
ser_clk = 0;
dac_sync = 0;
sdac(3);
sdac(DAC_VALUE);
dac_sync = 1;
}
dac2()
{
ser_clk = 0;
dac_sync = 0;
sdac(7);
sdac(DAC_VALUE);
dac_sync = 1;
}
adc()
{
char CH[8]= {0x0,0xc0,0x90,0xd0,0xa0,0xe0,0xb0,0xf0};
char A,J;
ser_di = 1;
adc_cs = 1;
ser_clk = 0;
dac_sync ;
//p1.0
ser_clk ;
//p1.1
ser_di ;
//p1.2
ser_d0 ;
//p1.3
adc_cs ;
//p1.4
//clear SYNC
//clear SYNC
//for START bit
90
SES Scientific Educational Systems