ADC Reading in the Cloud
응답
19. 2. 25 오후 4:23

Hello community

I want to read GPIO ADC PD6 pin values ​​from the XDK Gateway in the cloud, can someone help me with this?

0 (0 투표)
RE: ADC Reading in the Cloud
응답
19. 2. 28 오전 6:19 as a reply to Andres Rivera.

Hi Andres Rivera,

For reading GPIO ADC PD6 pin values, following the below sample code for ADC initialization,

/* ADC pin and channel configuration*/
BSP_ExtensionPort_ConnectAdc(BSP_EXTENSIONPORT_GPIO_PD6);
BSP_ExtensionPort_EnableAdc(BSP_EXTENSIONPORT_GPIO_PD6);

/* ADC central module initialization */
AdcCentral_Init();

/* ADC  configuration which includes callback mapping */
AdcCentral_ConfigScan_T configScan;
#define TIMER_SAMPLING_FREQ             5000UL  /**< ADC Signal sampling frequency in Hz */
#define NO_OF_CHANNELS_USED				UINT32_C(1)
#define ADC_CENTRAL_NO_OF_SAMPLES       200
#define ADC_BUFFER_SIZE					(ADC_CENTRAL_NO_OF_SAMPLES * NO_OF_CHANNELS_USED)
uint16_t ScanData[ADC_BUFFER_SIZE]; /**< LEM sensor ADC user buffer for CH5 */

/**
 * @brief ADC Central callback function define per your need
 * @param[out] adc handle not used.
 * @param[out] SamplingFreq which tells the adc samples collected frequency.
 * @param[out] bufferPtr which is pointer to the application provided adc buffer which holds adc samples for  Ch6.
 */
void ADCCallback(ADC_T adc, uint32_t SamplingFreq, uint16_t* bufferPtr)
{
    /* Process the data from bufferPtr per your application need */
}

configScan.BufferPtr = (uint16_t *) ScanData;
configScan.Appcallback = ADCCallback;
configScan.ChannelScanMask = (uint32_t) ADC_ENABLE_CH6_SCAN;
configScan.SamplingRateInHz = TIMER_SAMPLING_FREQ;
AdcCentral_StartScan(BSP_Adc_GetHandle(), &configScan);



Process the data from the ADC callback and sent the data via desired protocol (HTTP/MQTT).

For more information about ADC implementation refer xdk110/Common/source/sensors/Lem.c

For more information about data transmission refer xdk110/Apps/HttpExampleClient or xdk110/Apps/SendDataOverMQTT

Best regards,

Padmapriya.

0 (0 투표)