4 Replies Latest reply on Mar 3, 2020 6:19 PM by pime_2449811

    PSoC6 ModusToolbox cyhal_adc library

    pime_2449811

      I am working on a project to read a voltage from GPIO pin (e.g. P10_0) and send the ADC data with BLE link to a cellphone.  This project is based on:

      PSoC 6

      ModusToolbox

      cyhal_adc library

       

      I started with “BLE Battery Level FreeRTOS” example code.  

       

      In main.c, I added the following code to start adc

       

      ...

       

      /*Initialize GPIO Pin*/

      cyhal_gpio_init((cyhal_gpio_t)P10_0, CYHAL_GPIO_DIR_INPUT,

                                     CYHAL_GPIO_DRIVE_PULLDOWN, 1U);

      /* Turn on the ADC for the specified pin */

      cyhal_adc_t adc;

      cyhal_adc_channel_t channel;

      cy_rslt_t m_result =cyhal_adc_init( &adc, (cyhal_gpio_t)P10_0, (cyhal_clock_divider_t*)NULL );

      cyhal_adc_channel_init( &channel, &adc, (cyhal_gpio_t)P10_0 );

      if (CY_RSLT_SUCCESS == m_result){

      cyhal_gpio_write((cyhal_gpio_t)CYBSP_USER_LED2, CYBSP_LED_STATE_ON);

      }

      ......

      m_result is to check if adc initialization is successful.  It is NOT.  I am wondering if I missed something before these codes?  Any help would be greatly appreciated.

      Ping