From sensorPIR and DoorLockKeyPad , it can know device use adc0 as ad check pin , but from zgm130S data sheet , adc0 can be PA0 or PA1 , in this case , how can I use PA1 as AD input ? I try to add external power 2.3v to PA1 pin , it cannot work : Battery voltage: 3345mV
After setting , It cannot work , If no input the pa1 is 3.3V , after input 2.1v external voltage , and get the PA1 value : Battery voltage: 3105mV, actual it is 2.8V.
0
Do you replace "ADC_Input_Select(adcPosSelAVDD);" with " ADC_Input_Select(adcPosSelAPORT3YCH9); " in ZAF_ADC_Measure_VSupply()?
2. Create a timer to call CC_Battery_BatteryGet_handler
void
ZCB_adcCheckTimerCallback(SSwTimer *pTimer)
{
CC_Battery_BatteryGet_handler(ENDPOINT_ROOT);
}
3. Change adcPosSelAVDD to adcPosSelAPORT3YCH9 in ZAF_ADC_Measure_VSupply .
4. Change RX0 to PC10 in board.c
#define UART0_RX_PORT gpioPortC
#define UART0_RX_PIN 10
5. Apply DC power 2.4V to PA1 and link GND with DC power , check the timer log and see the result .
0
I use SDK 7.15.1 and do the following changes.
1. In board.c, replace "#define UART0_RX_PORT gpioPortA" with "#define UART0_RX_PORT gpioPortC" and "#define UART0_RX_PIN 1" with "#define UART0_RX_PIN 10".
2. In ZAF_adc.c, replace "ADC_Input_Select(adcPosSelAVDD);" with "ADC_Input_Select(adcPosSelAPORT3YCH9);" inside ZAF_ADC_Measure_VSupply.
3. In sensorPIR.c, add "CheckBatteryLevel();" in "if (BTN_EVENT_SHORT_PRESS(BATTERY_REPORT_BTN) == (BUTTON_EVENT)event){...}" so it will trigger ADC reading on PA1 when you press button.
0
I did as what you said , it also cannot work , here is my hardware design . As expect , it should be 1650mV , but result is 3223mV. If not link PA1, 3-way-in is 1.65V。 So it is right , but I don't know why get the ad wrong value.
0
Do you use scope or multimeter to check real voltage on PA1?
0
Yes . Real voltage on PA1 is 3330mV , it is strange . If not link 3-way-in ,just testing PA1, it is 3338mV .
0
When using the PA1 as ADC input, please connect the VCOM_ENABLE/PA5/P16 pin to GND to disable the VCOM , please see UG477 for more information about the connectors.
Zwave 700 how can I use PA1 as ad input
From sensorPIR and DoorLockKeyPad , it can know device use adc0 as ad check pin , but from zgm130S data sheet , adc0 can be PA0 or PA1 , in this case , how can I use PA1 as AD input ? I try to add external power 2.3v to PA1 pin , it cannot work : Battery voltage: 3345mV
After setting , It cannot work , If no input the pa1 is 3.3V , after input 2.1v external voltage , and get the PA1 value : Battery voltage: 3105mV, actual it is 2.8V.
Yes , here is my code :
static void ADC_Input_Select(ADC_PosSel_TypeDef input)
{
ADC_InitSingle_TypeDef singleInit = ADC_INITSINGLE_DEFAULT;
// Init for single conversion use, use 5V reference
singleInit.reference = adcRef5V;
singleInit.posSel = input;
singleInit.resolution = adcRes12Bit;
singleInit.acqTime = adcAcqTime256;
ADC_InitSingle(ADC0, &singleInit);
}
uint32_t ZAF_ADC_Measure_VSupply(void)
{
uint32_t sampleAVDD;
// Measure AVDD (battery supply voltage level)
// ADC_Input_Select(adcPosSelAVDD);
ADC_Input_Select(adcPosSelAPORT3YCH9);
ADC_Start(ADC0, adcStartSingle);
while (ADC0->STATUS & ADC_STATUS_SINGLEACT) ;
sampleAVDD = ADC_DataSingleGet(ADC0);
// Convert to mV (5V ref and 12 bit resolution)
sampleAVDD = (sampleAVDD * 5 * 1000) / 4096;
return sampleAVDD;
}
void ZAF_ADC_Enable(void)
{
ADC_Init_TypeDef adcInit = ADC_INIT_DEFAULT;
// Enable ADC clock
CMU_ClockEnable(cmuClock_ADC0, true);
// Setup ADC
adcInit.timebase = ADC_TimebaseCalc(0);
// Set ADC clock to 7 MHz, use default HFPERCLK
adcInit.prescale = ADC_PrescaleCalc(7000000, 0);
ADC_Init(ADC0, &adcInit);
}
void ZAF_ADC_Disable(void)
{
ADC_Reset(ADC0);
// Disable ADC clock
CMU_ClockEnable(cmuClock_ADC0, false);
}
Hi,
When did you take the ADC measurement? Keep in mind that ADC cannot work in EM4. Did you wake up the device and then take ADC measurements?
Regards,
Tony
Also, did you disable UART0 since PA1 and PA0 are configured as UART0 TX and RX pins if DEBUGPRINT is enabled?
Hi TonyQ;
1. I'm using SwitchOnOff demo to test AD , so device doesn't go into sleep .
2. I have changed UART0 RX pin to PC10 in board.c file
3.Using a timer frequency to check ad
Hi YK ,
Can you attached your hex file for me to test ? Besides can you tell me below question :
1. What sdk do you use ?
2. How do you get the ad value , just call CC_Battery_BatteryGet_handler() ??
I'm using sdk 7.13.5.0 for testing and create sensorPIR demo , the result same as what I did in SwitchOnOff .Here is my change for demo :
1. Change device mask #define DEVICE_OPTIONS_MASK APPLICATION_NODEINFO_LISTENING
2. Create a timer to call CC_Battery_BatteryGet_handler
void
ZCB_adcCheckTimerCallback(SSwTimer *pTimer)
{
CC_Battery_BatteryGet_handler(ENDPOINT_ROOT);
}
3. Change adcPosSelAVDD to adcPosSelAPORT3YCH9 in ZAF_ADC_Measure_VSupply .
4. Change RX0 to PC10 in board.c
#define UART0_RX_PORT gpioPortC
#define UART0_RX_PIN 10
5. Apply DC power 2.4V to PA1 and link GND with DC power , check the timer log and see the result .
I use SDK 7.15.1 and do the following changes.
1. In board.c, replace "#define UART0_RX_PORT gpioPortA" with "#define UART0_RX_PORT gpioPortC" and "#define UART0_RX_PIN 1" with "#define UART0_RX_PIN 10".
2. In ZAF_adc.c, replace "ADC_Input_Select(adcPosSelAVDD);" with "ADC_Input_Select(adcPosSelAPORT3YCH9);" inside ZAF_ADC_Measure_VSupply.
3. In sensorPIR.c, add "CheckBatteryLevel();" in "if (BTN_EVENT_SHORT_PRESS(BATTERY_REPORT_BTN) == (BUTTON_EVENT)event){...}" so it will trigger ADC reading on PA1 when you press button.
I did as what you said , it also cannot work , here is my hardware design . As expect , it should be 1650mV , but result is 3223mV. If not link PA1, 3-way-in is 1.65V。 So it is right , but I don't know why get the ad wrong value.
When using the PA1 as ADC input, please connect the VCOM_ENABLE/PA5/P16 pin to GND to disable the VCOM , please see UG477 for more information about the connectors.