WHY ADC_read not work in this combination?

General discussion on mikroPascal PRO for ARM.
Post Reply
Author
Message
corado
Posts: 399
Joined: 28 Mar 2009 11:03

WHY ADC_read not work in this combination?

#1 Post by corado » 07 Oct 2023 19:58

adc_value is real/float


This doesn't work

Code: Select all

  adc_value :=(ADC1_Get_Sample(1) / 4096)*3.3; 
OR this

Code: Select all

Floattostr(((ADC1_Get_Sample(1) / 4096)*3.3),adc_value_str);
This works

Code: Select all

 adc_value := ADC1_Get_Sample(1);
  adc_value :=(adc_value / 4096)*3.3;
Why, dos the first one always show 0?

corado
Posts: 399
Joined: 28 Mar 2009 11:03

Re: WHY ADC_read not work in this combination?

#2 Post by corado » 07 Oct 2023 20:29

Oh, the failure was
4096, correct is 4096.0
This is correct
Floattostr(((ADC1_Get_Sample(1) / 4096.0)*3.3),adc_value_str);

Post Reply

Return to “mikroPascal PRO for ARM General”