4 Replies Latest reply on Nov 14, 2019 9:47 PM by ShifangZ_26

    [TYPE_C Power SDK - ADC]

    ivle_1343546

      I use TYPE_C Power SDK ( CYPD4126 ) to develop project ,

      We use one ADC input ( P2.7 ) to meause voltage, but vaule always get 0.

      We use meter to measure P2.7, we can see the voltage changing on P2.7

       

      Please help us to solve ADC sample issue.

       

      below link is our test code :

      https://mega.nz/#!ik9CgSLI!kgT5xdXLexPxNFVw4YiL-KPy45O3euHHNjLClbHDK-o

        • 1. Re: [TYPE_C Power SDK - ADC]
          ShifangZ_26

          Hi Ivan,

           

          I cannot get the test code from your link yo view your code, but I am assured that CCG4 CYPD4126 do not have P2.7, I have screen copy the PORT assignments for your reference. You should check the pin number on your schematic and make sure the GPIO is routing to Px.x.

           

          Best Regards,

          Lisa

          • 2. Re: [TYPE_C Power SDK - ADC]
            ivle_1343546

            We use 40pin QFN

             

                    hsiom_set_config(GPIO_PORT_2_PIN_7, HSIOM_MODE_AMUXA);

                    CyDelayUs(200);

                    /* Take ADC sample. */

                    level = pd_adc_sample (1, PD_ADC_ID_1, PD_ADC_INPUT_AMUX_A);

                    //therm_volt = pd_adc_level_to_volt (port, PD_ADC_ID_1, level);

                   

                    hsiom_set_config(GPIO_PORT_2_PIN_7, HSIOM_MODE_GPIO);

                   

                    SW_Tx_UART_1_PutChar(level);

            • 3. Re: [TYPE_C Power SDK - ADC]
              ivle_1343546

              Do you have any update ?

              • 4. Re: [TYPE_C Power SDK - ADC]
                ShifangZ_26

                Hi ,

                 

                There is example code I was used in CYPD4236 board and confirmed that the function is working. Please kindly make sure you instant the port value with port 1 (port =1).

                 

                uint8_t Measure_PORT (uint8_t port)

                {

                  uint8_t level = 0, i=0;

                  /* Configure GPIO. */

                  gpio_hsiom_set_config(GPIO_PORT_2_PIN_7, HSIOM_MODE_AMUXB,

                  GPIO_DM_HIZ_ANALOG, 0);

                  CyDelayUs(120);

                  /*

                  * Re-run caliberation every time to ensure that VDDD or the measurement

                  * does not break.

                  */

                  pd_adc_calibrate (port, PD_ADC_ID_1);

                  for(i = 0; i < 2; i++){

                  level = pd_adc_level_to_volt(port,PD_ADC_ID_1,pd_adc_sample(port, PD_ADC_ID_1, PD_ADC_INPUT_AMUX_B));

                  CyDelayUs(20);

                  }

                  

                  hsiom_set_config(GPIO_PORT_2_PIN_7, HSIOM_MODE_GPIO);

                  return level;

                }

                 

                Best Regards,

                Lisa