Hi
I work on the TMS320VC5505 and I want to use the SAR to measure the battery's voltage. I have done it without use CSL. I use the channel1. And I don't understand the value in SARDATA. For example: if I supply my board with 2.6V, my voltage is divided by two before enter in GPAI0 with a divider (two resistor of 100K).
I should obtain in SARDATA . (1024 / 3.6)*1.3 / 8=46.2 but I have 207. Are There some registers to set to activate the divider ?have I done some errors in my calcul ?
My other problem is that for a same voltage, my value in SARDATA fluctuate. Thus for 2.6V my value fluctuate between 203 and 207! Is it normal ?
For finish I wanted to use the channel2 because I don't want to divid by eight my value but I have always 1023 in SARDATA?
This is my code :
For initialize:
void Init_SAR(void)
{
*SARCTRL = 0x1C00; // Select channel 1 througth GPAIN0
*SARCLKCTRL = 0x7fff;
*SARPINCTRL = 0x3402; // SARPINCTRL SAR A/D Reference and Pin Control Register
// HALF : disable
// GND0ON : enable
//AVDDMEAS : disable
// TOUCHSCREENMODE :disable
//REFAVDDSEL :Reference Voltage based on Bandgap
// REFLVSEL 0:Bandgap-Based Reference Voltage set to 0.8V.
//SARPWRUP 0:SAR analog Powered down.
//PWRUPBIAS 1:Powered Up. Required setting for performing A/D conversions.
*SARGPOCTRL = 0;
}
For activate :
Void SAR(void)
{
*SARPINCTRL = 0x3402;
*SARCTRL = 0x9C00; //start conversion
do // check that the conversion has started !
{
val = *SARDATA;
}while(!(val & 0x8000));
}
For read :
Void SAR_isr(Void)
{
int testval;
int i;
LgUns val,mvolt_value ;
val = *SARDATA;
val=val & 0x03ff;
}
Thanks for your help
Julien