Demo code questions

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Demo code questions

2,061件の閲覧回数
jefff
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 件の賞賛
返信
4 返答(返信)

1,791件の閲覧回数
danielhadad
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 件の賞賛
返信

1,791件の閲覧回数
craigs
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 件の賞賛
返信

1,791件の閲覧回数
jefff
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 件の賞賛
返信

1,791件の閲覧回数
odedyishay
NXP Employee
NXP Employee

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

-Oded

0 件の賞賛
返信