1236 views|5 replies

6822

Posts

11

Resources
The OP
 

[Xianji HPM6750EVK2 Review] Experience the ADC function [Copy link]

 

1. Create a new RTT project and add the ADC driver to the project:

2. After saving the project, add the test code.
3. We connect J10 according to the schematic diagram, only PE29 is the output channel of ADC3
[attach]786311 [/attach]
4. First define the channel and task

```
#define ADC_DEV_NAME "adc3" /* ADC device name*/
#define ADC_DEV_CHANNEL 2 /* ADC channel*/
#define REFER_VOLTAGE 330 /* Reference voltage 3.3V, data accuracy multiplied by 100 to retain 2 decimal places*/
#define CONVERT_BITS (1 << 16) /* Conversion bit number is 16 bits*/
```

5. Add tasks:

```
static void Adc_entry(void* paremeter)
{
rt_adc_device_t adc_dev;
rt_uint32_t value,vol;
rt_err_t ret = RT_EOK;

adc_dev = (rt_adc_device_t)rt_device_find(ADC_DEV_NAME);
if (adc_dev == RT_NULL)
{
rt_kprintf("adc sample run failed! can't find %s device!\n", ADC_DEV_NAME);
}
/* Enable device*/
ret = rt_adc_enable(adc_dev, ADC_DEV_CHANNEL);
if(ret == RT_EOK)
{
rt_kprintf("adc sample run success! find %s device!\n", ADC_DEV_NAME);
}
while(1)
{
/* Read sample value*/
value = rt_adc_read(adc_dev, ADC_DEV_CHANNEL);
rt_kprintf("the value is :%d \n", value);
/* Convert to corresponding voltage value*/
vol = value * REFER_VOLTAGE / CONVERT_BITS;
rt_kprintf("the voltage is :%d.%02d \n", vol / 100, vol % 100);

rt_thread_delay(500);
}
}
```

7. Enable tasks in the main function

```
Adc_thread = rt_thread_create("adc1",
Adc_entry,
RT_NULL,
512,
16,
20);
if(Adc_thread != RT_NULL)
rt_thread_startup(Adc_thread);
else
return -1;
```
After downloading to the development board, the effect is as follows:

【Summarize】

HPM6750 has 16-bit ADC and 12-bit ADC. After testing, the effect is very good.

image.png (197.82 KB, downloads: 0)

image.png
This post is from Domestic Chip Exchange

Latest reply

Friends must pay attention, if you buy a JLINK debugger, you must buy JLINK V11 or above. Don’t ask me how I know this, it’s very expensive. For those who don't have an onboard debugger for HPM6750EVK2, you may want to try the onboard FT2232HL. You can use this FT2232HL debugger on Taobao. It has the same functions as the official onboard debugger and is very affordable. For details, please see the purchase link http://e.tb.cn/h.gx7VTHWCvoFnNkN?tk=fCJQ3n9ZOAF   Details Published on 2024-10-25 16:18
 
 

364

Posts

0

Resources
2
 

What is the accuracy? What is the accuracy of the external voltage divider resistor?

This post is from Domestic Chip Exchange

Comments

There is also accuracy testing. I am only learning how to read the data now, and will run this test in the next article.  Details Published on 2024-2-18 09:26
 
 
 

6822

Posts

11

Resources
3
 
LitchiCheng posted on 2024-2-18 09:24 How is the accuracy? What is the accuracy of the external voltage divider resistor?

There is also accuracy testing. Now I am only learning how to read the data, and I will run this test in the next article.

This post is from Domestic Chip Exchange

Comments

OK, all ADC functions are available, but the accuracy varies from one manufacturer to another.  Details Published on 2024-2-18 11:46
 
 
 

364

Posts

0

Resources
4
 
lugl4313820 posted on 2024-2-18 09:26 There is also a precision test. I am only learning how to read the data now. I will run a test in this area in the next article.

OK, all ADC functions are available, but the accuracy varies from one manufacturer to another.

This post is from Domestic Chip Exchange
 
 
 

4

Posts

0

Resources
5
 
LitchiCheng posted on 2024-2-18 11:46 Okay, all ADCs have the same functions, but the accuracy of each one is different

Fei Gong said there is no 16-bit

This post is from Domestic Chip Exchange
 
 
 

1

Posts

0

Resources
6
 

Friends must pay attention, if you buy a JLINK debugger, you must buy JLINK V11 or above. Don’t ask me how I know this, it’s very expensive.

For those who don't have an onboard debugger for HPM6750EVK2, you may want to try the onboard FT2232HL. You can use this FT2232HL debugger on Taobao. It has the same functions as the official onboard debugger and is very affordable. For details, please see the purchase link http://e.tb.cn/h.gx7VTHWCvoFnNkN?tk=fCJQ3n9ZOAF

This post is from Domestic Chip Exchange
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list