Skip navigation
Home > All Places > MCU > PSoC 4 MCU Community > Blog > Authors RyanZ_36

PSoC 4 MCU Community

1 Post authored by: RyanZ_36 Moderator
RyanZ_36

10-bit ADC CSD Code Example

Posted by RyanZ_36 Moderator Dec 3, 2018

Hello Everyone!

 

10-bit ADC for PSoC 4 is a triggered analog to digital converter. The Component includes a customizer to configure the initial state and APIs to control the Component from application firmware.

Some one may want to use 10-bit ADC CSD Component, but doesn't find its code example in PSoC Creator.

Here is a code example of the component for your reference.

You just need to drag the component to your TopDesign.cysch, give it an instance name, select 10-bit or 8-bit you want to use. Ah! Don't forget to select its number of input channels (If you have read its datasheet carefully, you will find that the channel number is up to 10 ). Then add the following code(easy code, right?).

 

#include "project.h"

volatile uint16 ADC_CSD_result;

int main(void)
{
    CyGlobalIntEnable; /* Enable global interrupts. */

    /* Place your initialization/startup code here (e.g. MyInst_Start()) */    
    ADC_CSD_Start();
    
    for(;;)
    {
        /* Place your application code here. */
        while(ADC_CSD_Calibrate());
        ADC_CSD_result = ADC_CSD_ReadResult_mVolts(0);
        CyDelay(1);
    }
}

 

I tested the code on KIT-041-40XX. There is a sliding resistor(The pin should be P2.4) on the kit.

Built and Programmed successfully. Entered in PSoC Creator debug mode. I got the result of the ADC:

Note that:

1. Don't need Cmod for this component;

2. CapSense Component uses same internal resource with the 10-bit ADC, so you can only choose one between these two in one project.

 

Hope it can help you!