5970 views|2 replies

1140

Posts

0

Resources
The OP
 

IWR1642/AWR1642 GPADC Function Introduction and Implementation [Copy link]

The millimeter wave sensor chip of IWR1642 integrates the function of general-purpose ADC (GPADC). Users can use GPADC to monitor external voltages, such as power supply voltage. The ADC sampling rate on the IWR1642 is 625Ksps, the precision is 10-bit, and 6 ADC pins are provided for users to measure. Five ADCs support buffered mode and unbuffered mode, and one ADC only supports unbuffered mode. In unbuffered mode, the measurement range of the ADC is 0V~1.8V, while in buffered mode, the measurement range is 0.4V~1.3V.
GPADC itself is controlled by the radar subsystem. Users can obtain GPADC related information by calling the GPADC detection API in MSS or DSS and sending relevant requests to the radar subsystem. After receiving the ADC detection message, the radar subsystem will schedule ADC measurement and other RF and analog detection functions. Users can configure the ADC setting time, that is, how many sampling points to skip before officially adopting, and the number of continuous sampling points. The radar subsystem will send the minimum, maximum and average values of ADC sampling to the initiator of GPADC sampling (MSS or DSS) through messages at the end of a frame.
Precautions
There are two points to note here. One is the setting of the asynchronous message sending object in BSS. For the GPADC detection, the core that calls the configuration of GPADC will receive the message sent by BSS. One is the object of message sending under mmwave Link. The mmwave link message is used in the mmw demo, which is an asynchronous message configuration different from that of BSS. In the mmw demo, the return value of the message processing function MmwDemo_mssMmwaveEventCallbackFxn() in the MMS code is 0 by default, indicating that after receiving the message, the message also needs to be sent to DSS. So when MSS initiates the configuration of GPADC, by default, not only MSS will receive the GPADC message, but DSS will also receive the GPADC message. If DSS does not process the received GPADC message, an error will be reported on the DSS side. So if the DSP does not need to process related events, the processing of GPADC messages can be added to the MmwDemo_dssMmwaveEventCallbackFxn function on the DSP side, such as break after receiving the message. However, a better way is to set the return value of the corresponding message event to 1 on the MSS side. This can reduce the interruption of DSS. The default code MmwDemo_mssMmwaveEventCallbackFxn() function returns only one value. Because each core of mmw demo processes multiple messages, it is best to modify MmwDemo_mssMmwaveEventCallbackFxn so that the return value of the message that does not need to be passed to DSS is 1, and the return value that is required is 0. If the user needs to call the configuration code of GPADC on the DSS side, similar processing is also required.
GPADCFunction Implementation
The following takes MSS reading GPADC as an example to introduce how to implement the function of obtaining GPADC values multiple times in the mmw demo of mmWave SDK2.0. The following test is based on IWR1642 BOOST ES2.0. DSS can also use a similar method to read GPADC. First, you need to add the relevant code for GPADC configuration in mss_main.c. Each time you call to configure GPADC, you can receive a message related to GPADC and get the value of GPADC. If you need to read the value of GPADC multiple times, you need to call the configuration of GPADC multiple times. #include
#include
rlUInt8_t isGetGpAdcMeasData = 0U;
rlRecvdGpAdcData_t rcvGpAdcData = {0};
const rlGpAdcCfg_t gpAdcCfg =
{
    .enable = 0x3F,
.bufferEnable = 0,//0表示非缓冲模式,
                               //1表示使能缓冲模式,如果全部ADC使能缓冲模式则配置0x3F
    .numOfSamples[0].sampleCnt = 20,
    .numOfSamples[0].settlingTime = 3,
    .numOfSamples[1].sampleCnt = 14,
    .numOfSamples[1].settlingTime = 3,
    .numOfSamples[2].sampleCnt = 14,
    .numOfSamples[2].settlingTime = 3,
    .numOfSamples[3].sampleCnt = 14,
    .numOfSamples[3].settlingTime = 3,
    .numOfSamples[4].sampleCnt = 14,
    .numOfSamples[4].settlingTime = 3,
    .numOfSamples[5].sampleCnt = 14,
    .numOfSamples[5].settlingTime = 3,
    .numOfSamples[6].sampleCnt = 14,
    .numOfSamples[6].settlingTime = 3,
     .numOfSamples[7].sampleCnt = 14,
.numOfSamples[7].settlingTime = 3
.numOfSamples[8].sampleCnt = 14,
    .numOfSamples[8].settlingTime = 3,
     .numOfSamples[9].sampleCnt = 14,
    .numOfSamples[9].settlingTime = 3,
     .numOfSamples[10].sampleCnt = 14,
    .numOfSamples[10].settlingTime = 3,
     .numOfSamples[11].sampleCnt = 14,
    .reserved0 = 0
};
int32_t MmwaveLink_setGpAdcConfig (void)
{
   int32_t         retVal;
  
   retVal = rlSetGpAdcConfig(RL_DEVICE_MAP_INTERNAL_BSS, (rlGpAdcCfg_t*)&gpAdcCfg);
   /* Check for mmWaveLink API call status */
   if(retVal != 0)
   {
       /* Error: Link reported an issue. */
       System_printf("Error: rlSetGpAdcConfig retVal=%d\n", retVal);
       return -1;
   }
while(isGetGpAdcMeasData == 0U)
   {
       /* Sleep and poll again: */
       Task_sleep(1);
   }
   return 0;
}
       下面是具体调用GPADC配置的代码,可以添加在用户需要测试外部电压的地方。
                if (MmwaveLink_setGpAdcConfig() < 0)               
                {                 
                                System_printf ("Error: MmwaveLink_setGpAdcConfig\n");                                                                                       break;  
                }
        接下来在MSS侧添加GPADC消息的处理代码。下面的处理代码是在CCS输出窗口打印出ADC5的平均值。相关代码添加在MmwDemo_mssMmwaveEventCallbackFxn()函数里。将MmwDemo_mssMmwaveEventCallbackFxn函数的返回值设置为1,这样DSP就不会收到该消息,也就不需要在DSP侧添加消息处理代码了。当GPADC的配置代码被调用的时候,用户就可以在CCS打印输出窗口看到测量的GPADC的值。
               case RL_RF_AE_GPADC_MEAS_DATA_SB:
               {
                   isGetGpAdcMeasData = 1U;
                   memcpy(&rcvGpAdcData, payload, sizeof(rlRecvdGpAdcData_t));
                     System_printf ("GPADC value: %d V\n", rcvGpAdcData.sensor[4].avg);                           
                    break;
               }
     下面是在IWR1642BOOST上实测的数据和万用表测量的数据的比较。

万用表测量(V)

ADC5的平均值

GPADC值转换为电压 (V)

IWR1642 ES2.0 EVM

1.7176

980

1.8/1024*980=1.722656

0

0

1.8/1024*0=0


              
       上面介绍的GPADC使用方法适用于IWR1642/AWR1642,对于IWR1443/AWR1443上的GPADC的使用也是很好的参考。

This post is from DSP and ARM Processors

Latest reply

Really nice sharing.  Details Published on 2019-5-16 15:58
 

172

Posts

0

Resources
2
 
Thanks for sharing!
This post is from DSP and ARM Processors
 
 

2618

Posts

0

Resources
3
 
Really nice sharing.
This post is from DSP and ARM Processors
 
 
 

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