⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
2 posts / 0 new
Last post
dsandbue
Offline
Last seen:1 year 8 months ago
加入:2017-02-15 14:09
ADC在PXP-Reporter

Hello,

I'd like to implement an AD-Conversion in the PXP-Reporter demo. Therefore, I have implemented the following code in periph_init():

hw_gpio_set_pin_function(HW_GPIO_PORT_1, HW_GPIO_PIN_3, HW_GPIO_MODE_INPUT, HW_GPIO_FUNC_ADC); //ADC-Pin

静态gpadc_config cfg = {
.clock = HW_GPADC_CLOCK_INTERNAL,
.input_mode = HW_GPADC_INPUT_MODE_SINGLE_ENDED,
.input = HW_GPADC_INPUT_SE_P13,
.input_attenuator = true,
.oversampling = 1,
};

hw_gpadc_init(&cfg);

hw_gpadc_enable();

hw_gpadc_start();

Now, in the pxp_reporter_task, I check for this value every second like this:

unsigned int BattVoltAD = 0;

BattVoltAD = hw_gpadc_get_value();

hw_gpadc_start();

Unfortunately, the results are crap. It doesn't matter if I connect pin 1_3 to ground or to V33, the value jumps between 163 to 768. Am I missing something?

What is strange is that when I debug the code, it always hangs at sys_power_mgr.c -> pm_system_init() -> hw_gpadc_set_ldo_delay(0x0B);

Thanks in advance,
Philipp

Keywords:
ADC
Device:
IM_Dialog
Offline
Last seen:2 weeks 6 days ago
加入:2016-12-06 22:25
As you are using the PXP

As you are using the PXP Reporter demo then i assume the ADC adapter is in use i.e. the following is defined in custom_config_qspi.h:

#define dg_configGPADC_ADAPTER 1

If this is the case then i would recommend using the adapter to interface with the ADC, you can see how this is done by looking at the read_battery_level function in the file pxp_reporter_task.c. Take a look at the version of the function that gets included when dg_configUSE_SOC is not defined.