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

cross mob
VeSe_4052481
Level 1
Level 1

I have a  project whit a PSoc6  and a SAR ADC v 3.1.0 .

The program reads a single ended channel by PIN P10_0 but the value thta I read is always zero....

thank you...

The code is:

int main(void)

{

   

  /* UART initialization status */

    cy_en_scb_uart_status_t uart_status ;

    /* String to transmit over UART. */

    char uartString[200];

   

    static int16_t chanResult;

    static int16_t chanResultmV;

    /* ADC SAR initialization status */

    cy_en_sar_status_t status;

   

    char flag=0;

   

     /* Initialize UART operation. Config and Context structure is copied from Generated source. */

    uart_status  = Cy_SCB_UART_Init(Uart_Printf_HW, &Uart_Printf_config, &Uart_Printf_context);

    if(uart_status != CY_SCB_UART_SUCCESS)

    {

        HandleError();

    }

    Cy_SCB_UART_Enable(Uart_Printf_HW);

   

   

    /* Enable analog reference block needed by the SAR. */

    Cy_SysAnalog_Init(&Cy_SysAnalog_Fast_Local);

    Cy_SysAnalog_Enable();

    Cy_SAR_Enable(SAR);

    /* Initiate continuous conversions. */

    Cy_SAR_StartConvert(SAR, CY_SAR_START_CONVERT_CONTINUOUS);

 

    for(;;)

    { 

       

   /* Query end of conversion status. */

            status = Cy_SAR_IsEndConversion(SAR, CY_SAR_RETURN_STATUS);

            if (CY_SAR_SUCCESS == status)

            {     

                      chanResult = Cy_SAR_GetResult16(SAR, 0);

   

                     chanResultmV = Cy_SAR_CountsTo_mVolts(SAR, 0, chanResult);

                     /* Transmit results over UART. */

                    sprintf(uartString, "Volt  = %d \r\n", chanResultmV);

                    Cy_SCB_UART_PutString(Uart_Printf_HW, uartString);

                     Cy_GPIO_Inv(LED_Red_P0_3_PORT, LED_Red_P0_3_NUM);

                     CyDelay(200);

           

           }    }

}

pastedImage_33.png

pastedImage_36.png

0 Likes
1 Reply
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hello Veronica,

The ADC initialization in your code is not proper.  If you want to use the ADC with the configuration specified in the ADC config tab, you can simply call ADC_Start() API to start the component.

Best Regards,
Vasanth