RT-Thread / RT-Thread/rt-thread

psoc6-evaluationkit-062S2 ADC0 return value not right when connecting with VDD (3.3V)

Open
#8,466 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
12.2k
Forks
5.4k
Avg merge
4d 12h
Merged PRs (30d)
40

Description

Environment

board : psoc6-evaluationkit-062S2
bsp : PSOC62-IFX-EVAL-KIT 1.1.1
rt-thread : 5.0.1
RT-Thread Studio : 2.2.6

I had a problem when I tried to run this code below

#include <rtthread.h>

#define DBG_TAG "main"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>
#include <board.h>
#include <rtdevice.h>

#define ADC_DEV_NAME "adc1"
#define ADC_DEV_CHANNEL 0
#define REFER_VOLTAGE 330
#define CONVERT_BITS (1 << 12)

rt_thread_t Adc_thread = RT_NULL;

static void Adc_entry(void* paremeter);

int main(void)
{
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;
}

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);
}
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)
{
value = rt_adc_read(adc_dev, ADC_DEV_CHANNEL);
rt_kprintf("the value is :%d \n", value);
vol = value * REFER_VOLTAGE / CONVERT_BITS;
rt_kprintf("the voltage is :%d.%02d \n", vol / 100, vol % 100);
rt_thread_delay(500);
}
}


My Config

The ADC config is initialized as 12-bit resolution and I connect ADC0 (P10_0) with VDD
image

Result

The return value (2047) is not right which is half of 4096 (3.3V)
image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the ADC0/P10_0 configuration for the psoc6-evaluationkit-062S2 and trace the calls to rt_device_find, rt_adc_enable, and rt_adc_read. Reproduce the reading with ADC0 connected to VDD and compare the configured 12-bit resolution and board mapping with the observed 2047 value. Done means the ADC reports the expected full-scale value or the issue identifies the responsible configuration or driver behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.