Demo code questions

cancel
Showing results for 
Search instead for 
Did you mean: 

Demo code questions

302 Views
NXP Employee
NXP Employee

Can anyone explain where the value for ADC_MAX_CODE came from (I want to use this for another function I am doing with the ADC that has different limits and I need to understand where this came from)?

#define ADC_MAX_CODE    (4095)

//Pot Reading is Scaled to return a value of -1.0 to 1.0

float TFC_ReadPot(uint8_t Channel)

{

    if(Channel == 0)

        return ((float)PotADC_Value[0]/-((float)ADC_MAX_CODE/2.0))+1.0;

    else

        return ((float)PotADC_Value[1]/-((float)ADC_MAX_CODE/2.0))+1.0;

}

Question2: I am unable to use TERMINAL_PRINTF for printing out floating point numbers in the Code Warrior demo code FRDM-TFC_R1.0.zip ? Has anyone had any success?

Jeff

0 Kudos
4 Replies

32 Views
NXP Employee
NXP Employee

Jeffrey, I'll try to check in an update to the FRDM-TFC library-- checking it out now.   Looks like it works at least confirming with Excel-- haven't checked with Labview.

0 Kudos

32 Views
NXP Employee
NXP Employee

The equations and ADC_MAX_CODE value make sense if the ADC result is being read by the driver in 12-bit single-ended mode.

0 Kudos

32 Views
NXP Employee
NXP Employee

Ah, that makes perfect sense now. Thanks Craig.

And Oded. Yes, I found that %f works using mbed, but not in Code Warrior. I am using CW right now because I had trouble getting the demo code to work correctly for mbed.

0 Kudos

32 Views
NXP Employee
NXP Employee

We are using mbed, and the TERMINAL_PRINTF function prints floating points numbers correctly.

-Oded

0 Kudos