手册中没这么复杂
void READ_BANDGAP()
{
UINT8 BandgapHigh,BandgapLow;
Set_IAPEN; // Enable IAPEN
IAPAL = 0x0C;
IAPAH = 0x00;
IAPCN = 0x04;
set_IAPGO; // Trig set IAPGO
BandgapHigh = IAPFD;
IAPAL = 0x0d;
IAPAH = 0x00;
IAPCN = 0x04;
set_IAPGO; // Trig set IAPGO
BandgapLow = IAPFD;
BandgapLow = BandgapLow&0x0F;
Clr_IAPEN; // Disable IAPEN
Bandgap_Value = (BandgapHigh<<4)+BandgapLow;
Bandgap_Voltage = 3072/(0x1000/Bandgap_Value);
|