[TYPE_C Power SDK - ADC]

Announcements

Live Webinar: USB-C adoption. Simple & Cost-efficient solutions | April 18th @9am or 5pm CEST. Register now !

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Ivan_Lee
Level 5
Level 5
Distributor - Zenitron(GC)
100 replies posted 5 likes given 100 sign-ins

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

0 Likes
1 Solution
ShifangZ_26
Moderator
Moderator
Moderator
10 likes given 250 sign-ins 1000 replies posted

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

View solution in original post

0 Likes
4 Replies
ShifangZ_26
Moderator
Moderator
Moderator
10 likes given 250 sign-ins 1000 replies posted

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.

pastedImage_0.png

Best Regards,

Lisa

0 Likes
Ivan_Lee
Level 5
Level 5
Distributor - Zenitron(GC)
100 replies posted 5 likes given 100 sign-ins

We use 40pin QFN

pastedImage_0.png

        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);

0 Likes
Ivan_Lee
Level 5
Level 5
Distributor - Zenitron(GC)
100 replies posted 5 likes given 100 sign-ins

Do you have any update ?

0 Likes
ShifangZ_26
Moderator
Moderator
Moderator
10 likes given 250 sign-ins 1000 replies posted

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

0 Likes