Problem with ADCLCD

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

cross mob
Anonymous
Not applicable

 Hello...

   

            I am new to this cyppress controllers,I have just started to  working on CY7C6435648LTXC                           controller.I was doing ADC LCD coding.

   

            Here my problem is I am getting the ADC output,that again i am converting to voltage and                           displayiingbon LCD.That output voltage if i  am measureing with the multimeter that is not                           matching with the output voltage of  ADC.

   

            I am using external voltage divider circuit (potentiometer).

   

Can any one help me to sort out this.

   

And this is my code.

   

-=======================================================================================

   

#include <m8c.h>        // part specific constants and macros

   

#include "PSoCAPI.h"    // PSoC API definitions for all User Modules

   

#include "stdlib.h"

   

 

   

void main(void)

   

{

   

int val = 0, flag = 0;

   

float Scaling_factor,voltage;

   

//int Result;

   

char *Result;

   

int status;

   

   

  LCD_Start(); //Initializing LCD

   

flag   = (PRT0DR & 0x01);

   

   

MUX_CR1 = flag; //Connecting Output of ADC to P0.0

   

   

 

   

    ADCINC_Start(ADCINC_INPUT_ANALOG_BUS);//Start conversion

   

   

LCD_Position(0,0);

   

LCD_PrCString("ADC_OUTPUT = ");

   

       LCD_PrHexInt(flag);

   

LCD_Position(1,0);

   

LCD_PrCString("ADC_Vin=");

   

while(1)

   

{

   

   //val = ADCINC_GetSample(); //get the ADC value

   

   

  //while(ADCINC_fIsDataAvailable())

   

  {

   

val = ADCINC_GetSample();

   

LCD_Position(0,12);

   

LCD_PrHexInt(val);

   

   

voltage= (val /(float)1023);

   

voltage *= (3.3);

   

   

//voltage = (val * Scaling_factor); 

   

Result = ftoa(voltage , &status);

   

LCD_Position(1,8);

   

LCD_PrString(Result);

   

//LCD_PrCString("v");

   

}

   

   

   

}

   

}

   
        
0 Likes
5 Replies