3289 views|1 replies

335

Posts

0

Resources
The OP
 

【CH579M-R1】3. ADC internal temperature measurement, external channel and touch button test [Copy link]

 This post was last edited by yanxinboy on 2020-9-25 20:20

It’s very busy before the holidays and at the end of the month!

The CH579 integrates a 12-bit successive approximation analog-to-digital converter ADC with a maximum of 16 channels, supporting 14 external analog signal sources and 2 internal signal sources - an internal temperature detection channel and an internal battery voltage detection channel.

The input supports single-ended and differential input, and the PGA gain is optional (it is recommended to select the appropriate PGA gain according to the actual available measurement range in the manual to improve accuracy).

The ADC clock frequency is selected as 6, 8, 10, 12 divisions of CK32M, with a frequency range of 2.67MHz~5.33MHz, and the sampling rate is 1/16 of the clock frequency, which means that one sampling is completed in 16 clock cycles. This resolution and speed can fully meet the general analog quantity acquisition application.

Below is the block diagram and register list of the ADC for quick reference:

This experiment tests the single channel of ADC, internal temperature detection, and touch button detection:

Hardware connection: The external channels tested ADC channel 9 - PA0, ADC channel 3 - PA13, where PA0 was connected to 3.3V, and PA13 was also connected to 3.3V.

The ADC uses the data calibration function of the library function, and the manual describes the selection of PGA gain. The touch button uses 430BOOST-SENSE1. Connected to ADC channel 2 - PA12.

The experimental procedure is as follows:

int main()
{
    UINT8 i;
    signed short  RoughCalib_Value=0;		
    		RB_CFG_RESET_EN;
   
    DebugInit();
    PRINT( "Start @ChipID=%02X\n", R8_CHIP_ID );


    PRINT( "\n1.Temperature sampling...\n");
    ADC_InterTSSampInit();
    RoughCalib_Value = ADC_DataCalib_Rough();  
    for(i=0; i<20; i++)
    {
        abcBuff[i] = ADC_ExcutSingleConver() + RoughCalib_Value;     
    }
    for(i=0; i<20; i++)
    {
        PRINT("%u 'c ", ADC_GetCurrentTS( abcBuff[i] ));
    }PRINT("\n");
    

    PRINT( "\n2.Single channel sampling...\n");
    GPIOA_ModeCfg(GPIO_Pin_0, GPIO_ModeIN_Floating);
    ADC_ExtSingleChSampInit( SampleFreq_3_2, ADC_PGA_0 );
    

    GPIOA_ModeCfg(GPIO_Pin_5, GPIO_ModeIN_Floating);
    RoughCalib_Value = ADC_DataCalib_Rough();   
    PRINT("=%d \n", RoughCalib_Value);    
    
    ADC_ChannelCfg( 9 );        
    for(i=0; i<20; i++)
    {
        abcBuff[i] = ADC_ExcutSingleConver() + RoughCalib_Value;      
        ADC_DataCalib_Fine( &abcBuff[i], ADC_PGA_0 );
    }
    for(i=0; i<20; i++)
    {
        PRINT("%f V ", ((float)(abcBuff[i]))/4096*3.3);
    }PRINT("\n");
    


    PRINT( "\n4.TouchKey sampling...\n");    
    GPIOA_ModeCfg(GPIO_Pin_12, GPIO_ModeIN_Floating);
    TouchKey_ChSampInit();
    ADC_ChannelCfg( 2 );    

    for(i=0; i<20; i++)
    {
        abcBuff[i] = TouchKey_ExcutSingleConver(0x20); 
    }
    for(i=0; i<20; i++)
    {
        PRINT("%d ", abcBuff[i]);
    }PRINT("\n");
        
    

    PRINT( "\n4.Single channel sampling in interrupt mode...\n");    
    GPIOA_ModeCfg(GPIO_Pin_13, GPIO_ModeIN_Floating);
    ADC_ExtSingleChSampInit( SampleFreq_3_2, ADC_PGA_0 );
    ADC_ChannelCfg( 3 );
    NVIC_EnableIRQ(ADC_IRQn);
    adclen = 0;
    
    ADC_StartUp();  
    while(adclen < 20);
    NVIC_DisableIRQ(ADC_IRQn);
    for(i=0; i<20; i++)
    {
        PRINT("%f V ", ((float)(abcBuff[i]))/4096*3.3);
    }PRINT("\n");
    
    while(1);    
}


void ADC_IRQHandler(void)			
{
    if(ADC_GetITStatus())
    {
        abcBuff[adclen] = ADC_ReadConverValue();
        ADC_StartUp();
        adclen ++;
    }
}

The experimental data serial port output is as follows, where the values of the touch button in the non-touch state and the touch state do not seem to change much. Qinheng's manual does not have too much technical description about touch settings, PCB layout, etc. This may only be communicated with the official to obtain more technical information when the project requires it. If there are students who are good at touch debugging, please give me some advice on whether the current data is reasonable.

At the same time, we can see that after the ADC is calibrated with PGA gain, the actual effect is not as accurate as the value obtained by direct sampling. Qinheng's reference program requires that ADC1 be left floating when using coarse and fine adjustment. The ADC1 and PA5 of the board currently received are connected to the USB part, which may affect the sampling. We need to communicate with the official to understand. How to use this calibration, please give me some advice if you know.

In summary, the ADC internal temperature sampling is available, and the external sampling speed and accuracy should meet general use. For the touch buttons, we still need to communicate with the official to obtain other first-hand information. There is differential sampling in the sample program, but it is not convenient to test it for the time being.

Continue to adjust Bluetooth, thank you everyone!

Thanks for watching! Happy Mid-Autumn Festival and Happy National Day!

This post is from Domestic Chip Exchange

Latest reply

Qinheng CH579M-R1 Development Board Review Summary post: https://en.eeworld.com/bbs/thread-1140005-1-1.html   Details Published on 2020-9-27 10:42
 
 

1w

Posts

204

Resources
2
 

Qinheng CH579M-R1 Development Board Review

Summary post: https://en.eeworld.com/bbs/thread-1140005-1-1.html

This post is from Domestic Chip Exchange
Add and join groups EEWorld service account EEWorld subscription account Automotive development circle
Personal signature

玩板看这里:

http://en.eeworld.com/bbs/elecplay.html

EEWorld测评频道众多好板等你来玩,还可以来频道许愿树许愿说说你想要玩的板子,我们都在努力为大家实现!

 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

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