ADC and UART

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

cross mob
Anonymous
Not applicable

I am using delta sigma adc of 18 bit resolution, I tried to convert the data into string format and print in serial. But did not get result.

   

This is my code: 

   

#include <project.h>
#include <stdio.h>
int main()
{
    CyGlobalIntEnable; /* Enable global interrupts. */
    int16 result=0;
    float result1 = 0u;
    char8 resultStr[16u];
    char *resultstr= NULL;
    /* Place your initialization/startup code here (e.g. MyInst_Start()) */
    PWM_Start();
    ADC_Start();
    PGA_Start();
    UART_Start();
    ADC_StartConvert();   
    PWM_WritePeriod(100);
    PWM_WriteCompare(50);
    
    for(;;)
    {
         if(ADC_IsEndConversion(ADC_RETURN_STATUS))
        {
       result=ADC_GetResult32();
 
       result1=ADC_CountsTo_Volts(result);
       CyDelay(3000);
     
       sprintf((char *)resultStr,"%+1.2f",1.2663);
 
      CyDelay(1000);

    UART_PutString(resultStr);
        }
    }
        /* Place your application code here. */
    
}

0 Likes
3 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

It is always advisable to post the complete project,  so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.

   

Did you set "Use nelwlib nano float formatting" to true?

   

Did you set the heap size to >= 0x200 ?

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Thanks, here it is.

   

Where do I set the heap size?

   

I have even added -u _printf_float in command line setting.

0 Likes
Anonymous
Not applicable
0 Likes