FloatToStr(real,str) = ERROR with PRO Pascal Beta 3.2 why?

Beta Testing discussion on mikroPascal PRO for AVR.
Post Reply
Author
Message
K0RU
Posts: 19
Joined: 07 Mar 2010 03:06

FloatToStr(real,str) = ERROR with PRO Pascal Beta 3.2 why?

#1 Post by K0RU » 21 Jul 2010 19:34

inserting

FloatToStr(real,str) anywhere in the code results in

Compiler messages
----
0 139 All files Compiled in 15 ms
103 342 There is not enough ROM space __Lib_Lcd.mpas
365 342 There is not enough ROM space __Lib_Conversions.mpas
24 342 There is not enough ROM space AL500_Monitor.mpas
103 342 There is not enough ROM space __Lib_Lcd.mpas
365 342 There is not enough ROM space __Lib_Conversions.mpas
24 342 There is not enough ROM space AL500_Monitor.mpas
0 453 Unsuccessful linking 'AL500_Monitor.mppav' Unsuccessful linking 'AL500_Monitor.mppav'
0 102 Finished (with errors): 21 Jul 2010, 13:32:36 AL500_Monitor.mppav
---

Anyone know why?

Rob K0RU

K0RU
Posts: 19
Joined: 07 Mar 2010 03:06

Re: FloatToStr(real,str) = ERROR with PRO Pascal Beta 3.2 wh

#2 Post by K0RU » 21 Jul 2010 20:33

using the ATTINY26 chip and get this error (out of ROM)
but if I use the ATMEGA16 it works.

Reason? Out of ROM? makes no sense, because there is nothing else in the program except the following EXAMPLE.
for the FLOATTOSTR();

Code: Select all

program test;
var ff1, ff2, ff3 : real;
    txt : array[23] of char;


{ Declarations section }

begin
  ff1 := -374.2;
  ff2 := 123.456789;
  ff3 := 0.000001234;

  FloatToStr(ff1, txt);  // txt is "-374.2"
  FloatToStr(ff2, txt);  // txt is "123.4567"
  FloatToStr(ff3, txt);  // txt is "1.234e-6"
  { Main program }
end.
Strange, anyone tell me how to read the ADC and get it to display a decimal value on an LCD? Help in anyway you can would be appreciated. Thanks

Rob K0RU

User avatar
tihomir.losic
mikroElektronika team
Posts: 2138
Joined: 02 Dec 2009 14:16
Location: Serbia
Contact:

Re: FloatToStr(real,str) = ERROR with PRO Pascal Beta 3.2 wh

#3 Post by tihomir.losic » 22 Jul 2010 08:46

Hello,

please, follow this link:
http://www.atmel.com/dyn/resources/prod ... oc1477.pdf
you can see that ATtiny26 is 8-bit Microcontroller with
2K Bytes Flash.
This error appeared because your main function is bigger than 2K.

Also, ATmega16:
http://www.atmel.com/dyn/resources/prod ... oc2466.pdf
has 16K Bytes In-System Programmable Flash, and this is the reason why you did not
have this kind of error while you used ATmega16.

Best regards,

Losic Tihomir
mikroElektronika [Support team]

User avatar
tihomir.losic
mikroElektronika team
Posts: 2138
Joined: 02 Dec 2009 14:16
Location: Serbia
Contact:

Re: FloatToStr(real,str) = ERROR with PRO Pascal Beta 3.2 wh

#4 Post by tihomir.losic » 22 Jul 2010 08:53

K0RU wrote:Strange, anyone tell me how to read the ADC and get it to display a decimal value on an LCD? Help in anyway you can would be appreciated.
Hello,

please, try this code in order to try ADC_on_LCD example. I used EasyAVR6 and ATmega16.

Code: Select all

// LCD module connections
sbit LCD_RS at PORTD2_bit;
sbit LCD_EN at PORTD3_bit;
sbit LCD_D4 at PORTD4_bit;
sbit LCD_D5 at PORTD5_bit;
sbit LCD_D6 at PORTD6_bit;
sbit LCD_D7 at PORTD7_bit;

sbit LCD_RS_Direction at DDD2_bit;
sbit LCD_EN_Direction at DDD3_bit;
sbit LCD_D4_Direction at DDD4_bit;
sbit LCD_D5_Direction at DDD5_bit;
sbit LCD_D6_Direction at DDD6_bit;
sbit LCD_D7_Direction at DDD7_bit;
// End LCD module connections

unsigned char ch;
unsigned int adc_rd;
char *text;
long tlong;

void main() {

  LCD_Init();
  LCD_Cmd(_LCD_CURSOR_OFF);                // send command to LCD (cursor off)
  LCD_Cmd(_LCD_CLEAR);                     // send command  to LCD (clear LCD)

  text = "mikroElektronika";               // assign text to string
  LCD_Out(1,1,text);                       // print string a on LCD, 1st row, 1st column
  text = "LCD example";                    // assign text to string
  LCD_Out(2,1,text);                       // print string a on LCD, 2nd row, 1st column

  Delay_ms(2000);
  text  = "voltage:";                      // assign text to string
  while (1) {
    adc_rd  = ADC_read(2);                 // get ADC value from 2nd channel
    LCD_Out(2,1,text);                     // print string a on LCD, 2nd row, 1st column

    tlong = (long)adc_rd * 5000;           // covert adc reading to milivolts
    tlong = tlong / 1023;                  // 0..1023 -> 0-5000mV

    ch     = tlong / 1000;                 // extract volts digit
    LCD_Chr(2,9,48+ch);                    // write ASCII digit at 2nd row, 9th column
    LCD_Chr_CP('.');

    ch    = (tlong / 100) % 10;            // extract 0.1 volts digit
    LCD_Chr_CP(48+ch);                     // write ASCII digit at cursor point

    ch    = (tlong / 10) % 10;             // extract 0.01 volts digit
    LCD_Chr_CP(48+ch);                     // write ASCII digit at cursor point

    ch    = tlong % 10;                    // extract 0.001 volts digit
    LCD_Chr_CP(48+ch);                     // write ASCII digit at cursor point
    LCD_Chr_CP('V');

    Delay_ms(1);
  }
}//~!
Best regards,

Losic Tihomir
mikroElektronika [Support team]

piort
Posts: 1379
Joined: 28 Dec 2005 16:42
Location: Laval,Québec,Canada,Earth... :-)
Contact:

Re: FloatToStr(real,str) = ERROR with PRO Pascal Beta 3.2 wh

#5 Post by piort » 22 Jul 2010 11:25

hi,
@ Losic :
I didnt find this exemple anymore in the exemple folder. nor in this version of MP for AVR than in the older one and in the MP for Pic 3.8. BTW the code you have post is in C not in pascal ;-)

@Rob :FloatToStr procedure is a heavy one... you can see it in the statistic windows of the compiler (menu -> view -> statistic) .
If you use it 3 time, the compiler put the asm code 3 time in the final asm. (menu -> view -> assembly). So the trick is to create you own procedure where you use it one time... and call your procedure as many time you need it. You will save a lot of memory space with that trick. I use it for all built-in delay routine.

HTH a bit ;-)

User avatar
tihomir.losic
mikroElektronika team
Posts: 2138
Joined: 02 Dec 2009 14:16
Location: Serbia
Contact:

Re: FloatToStr(real,str) = ERROR with PRO Pascal Beta 3.2 wh

#6 Post by tihomir.losic » 22 Jul 2010 12:13

piort wrote:BTW the code you have post is in C not in pascal ;-)
Hello Piort,

I made oversight. Thank you for pointing me on this error.
Here is Pascal code:

Code: Select all

program Adc_On_Lcd;
// LCD module connections
var LCD_RS : sbit at PORTD2_bit;
var LCD_EN : sbit at PORTD3_bit;
var LCD_D4 : sbit at PORTD4_bit;
var LCD_D5 : sbit at PORTD5_bit;
var LCD_D6 : sbit at PORTD6_bit;
var LCD_D7 : sbit at PORTD7_bit;

var LCD_RS_Direction : sbit at DDD2_bit;
var LCD_EN_Direction : sbit at DDD3_bit;
var LCD_D4_Direction : sbit at DDD4_bit;
var LCD_D5_Direction : sbit at DDD5_bit;
var LCD_D6_Direction : sbit at DDD6_bit;
var LCD_D7_Direction : sbit at DDD7_bit;
// End LCD module connections

var ch: byte;
    adc_rd : word;
    Text : array[17] of char;
    tlong: longint;

begin

  Lcd_Init();
  Lcd_Cmd(_LCD_CURSOR_OFF);                // send command to LCD (cursor off)
  Lcd_Cmd(_LCD_CLEAR);                      // send command  to LCD (clear LCD)

  Text := 'mikroElektronika';              // assign text to string a
  Lcd_Out(1,1, Text);                      // print string a on LCD, 1st row, 1st column
  Delay_ms(2000);

  Text  := 'voltage:';                     // assign text to string a
  Lcd_Out(2, 1, Text);                     // print string a on LCD, 2nd row, 1st column
  Lcd_Chr(2, 14, 'V');

  while true do
    begin
      adc_rd     := ADC_read(2);           // get ADC value from 2nd channel
      tlong := adc_rd * 5005;
      adc_rd     := tlong shr 10;
      ch    := adc_rd div 1000;            // prepare value for diplay

      Lcd_Chr(2, 9, 48+ch);                // write ASCII at 2nd row, 9th column
      Lcd_Chr(2, 10, '.');

      ch    := (adc_rd div 100) mod 10;
      Lcd_Chr(2, 11, 48+ch);

      ch    := (adc_rd div 10) mod 10;
      Lcd_Chr(2, 12, 48+ch);

      ch    := adc_rd mod 10;
      Lcd_Chr(2, 13, 48+ch);

      delay_ms(1);
    end;
end.
Sorry for the inconvenience.

Best regards,

Losic Tihomir
mikroElektronika [Support team]

K0RU
Posts: 19
Joined: 07 Mar 2010 03:06

Re: FloatToStr(real,str) = ERROR with PRO Pascal Beta 3.2 wh

#7 Post by K0RU » 22 Jul 2010 14:12

WOW, Fantastic this explains everything for me then. I've jump to a different MCU (ATTINY88) and my original program is working fine. I will however reconsider now with this help and go back and try doing the code differently to see if I can utilize the ATTINY26 which I have alot of.

Thanks for everyones help.
Rob K0RU

Post Reply

Return to “mikroPascal PRO for AVR Beta Testing”