Bugs and new major revision

General discussion on mikroPascal for AVR.
Post Reply
Author
Message
JohannesH
Posts: 68
Joined: 23 Apr 2007 07:51

Bugs and new major revision

#1 Post by JohannesH » 20 Mar 2008 08:30

zristic from mikroElektronika team posted this within the mikroBasic AVR forum.
We have formed a new team for AVR compilers. Therefore, it is to expect a major revision for all AVR compilers in the incoming months. We have already made some progress in this context and I encourage you to continue reporting problems as it will help solving them.
I will take this as some kind of "restart" and I'm hopefully awaiting this new release.
Maybe it makes sense to start to list actual bugs and problems again here. I think it would be better to collect a list of bugs with "headers" only within replies to this thread and start a new thread with the details to each bug or problem. Also a link from the header to the detail thread would be helpful. Additionally a common starting text for the subject of the detail thread makes sense.
My proposal: "Bug in 4.0.0.2: xxxxxxxx" or "Problem in 4.0.0.2: xxxxxxxx" if it is not clear that it is a bug.

At least I would like to try it and hopefully other mikroElektronika AVR compiler users will follow!

Lets start again!
Regards
Johannes

JohannesH
Posts: 68
Joined: 23 Apr 2007 07:51

Constants within asm statements

#2 Post by JohannesH » 20 Mar 2008 08:58

It is not possible to use defined constants within asm statements.

...
const const1 = 7;
...
asm
LDI Rxx, const1
end;
...

produces error message.

Details: http://www.mikroe.com/forum/viewtopic.php?t=14099

JohannesH

JohannesH
Posts: 68
Joined: 23 Apr 2007 07:51

Unit structure - prototypes - encapsulation

#3 Post by JohannesH » 20 Mar 2008 09:20

The unit structure does not work currently:

Prototypes lead to compiler error "Procedure already defined".

All procedures and functions within the implementation section of a unit are visible outside.

Details: http://www.mikroe.com/forum/viewtopic.php?p=70951#70951

Johannes

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

#4 Post by yo2lio » 20 Mar 2008 09:42

Hi,

1.This is High Level Language Compiler, not ASM compiler.
You can not use defined constants in ASM.

2.Unit structure work correctly !

Code: Select all

unit My_unit;

const c1 = 7;

var aa,bb,cc,dd,ee : byte;

implementation

procedure proc_1;
begin

end;

procedure proc_n;
begin

end;

end;
3.If want you can combine ASM language with Pascal language :

Code: Select all

unit string_unit;

var
  XPtr:^byte; absolute 0x1A; volatile;register;
  YPtr:^byte; absolute 0x1C; volatile;register;
  ZPtr:^byte; absolute 0x1E; volatile;register;

implementation

function mem_Chr(p1 : word; ch : char; n : byte) : byte;
var i: byte;
begin
  i := 0;
  result := $FF;
  asm
    PUSH R26
    PUSH R27
    PUSH R30
    PUSH R31
  end;
  XPtr := p1;
  while i < n do
    begin
      asm
        LD R25,X+
      end;
      if R25 = ch then break;
      inc(i);
    end;
  asm
    POP R31
    POP R30
    POP R27
    POP R26
  end;
  if i < n then result := i;
end;

function Str_Len(var data_str : string[$FF]) : byte;
begin
  asm
    PUSH R26
    PUSH R27
    PUSH R30
    PUSH R31
  end;
  XPtr := @data_str;
  asm
la1:
    LD R25,X+
    CPI R25,0
    BRNE la1
    LD R25,-X
  end;
  result := XPtr - @data_str;
  asm
    POP R31
    POP R30
    POP R27
    POP R26
  end;
end;

end;
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

JohannesH
Posts: 68
Joined: 23 Apr 2007 07:51

#5 Post by JohannesH » 20 Mar 2008 12:02

yo2lio wrote:Hi,

1.This is High Level Language Compiler, not ASM compiler.
You can not use defined constants in ASM.

2.Unit structure work correctly !

Code: Select all

unit My_unit;

const c1 = 7;

var aa,bb,cc,dd,ee : byte;

implementation

procedure proc_1;
begin

end;

procedure proc_n;
begin

end;

end;
3.If want you can combine ASM language with Pascal language :

Code: Select all

unit string_unit;

var
  XPtr:^byte; absolute 0x1A; volatile;register;
  YPtr:^byte; absolute 0x1C; volatile;register;
  ZPtr:^byte; absolute 0x1E; volatile;register;

implementation

function mem_Chr(p1 : word; ch : char; n : byte) : byte;
var i: byte;
begin
  i := 0;
  result := $FF;
  asm
    PUSH R26
    PUSH R27
    PUSH R30
    PUSH R31
  end;
  XPtr := p1;
  while i < n do
    begin
      asm
        LD R25,X+
      end;
      if R25 = ch then break;
      inc(i);
    end;
  asm
    POP R31
    POP R30
    POP R27
    POP R26
  end;
  if i < n then result := i;
end;

function Str_Len(var data_str : string[$FF]) : byte;
begin
  asm
    PUSH R26
    PUSH R27
    PUSH R30
    PUSH R31
  end;
  XPtr := @data_str;
  asm
la1:
    LD R25,X+
    CPI R25,0
    BRNE la1
    LD R25,-X
  end;
  result := XPtr - @data_str;
  asm
    POP R31
    POP R30
    POP R27
    POP R26
  end;
end;

end;
Hi!
Thank you for answering.

at 1.
I know that Pascal is a high level Language but it is for mikro controllers and there is the asm statement.
I was just asking why the use of symbolic constants does not work (the use of variables does work).
Even more I cannot understand why it should not be supported because of the fact that the unit where the constant is used within actually compiles correct (success message) but the main program which uses the unit gives the problem when compiled? Linker problem?

at 2.
You have not read what the documentation says on page 44 about unit structure. There you see that you should use procedure and function prototypes BEFORE "implementation". Everything declared/defined within the implementation should not be visible outside the unit - therefore the prototypes before "implementation". All that does not work currently.

at 3.
I know about this and it is very helpful when writing libs to access hardware modules. Currently I'm missing the support for using constants.
BTW: In your example you use linker directives "volatile" and "register". I could not find anything about this within the documentation. Please can you explain this directives in detail?

Regards
Johannes

pykedgew
Posts: 164
Joined: 10 Dec 2005 02:22
Location: Brisbane Australia

#6 Post by pykedgew » 20 Mar 2008 14:24

Hi

Am using the full licence version of "MikroPascal for AVR 4.0.0.2"

That will be fantastic & having fresh minds will pave the way of improving the compiler.
At least things are going into a positive direction.

A nice recommendation if there can be a way of porting the generated assembler code to AVRStudio for stimulation.

Detailed Statistics
Procedures (Details) Window is Missing.
Any chance this maybe added back into the program ?

See below are some of the problems I have encounter in the past.

Kind Regards
Ken


--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[1] Accessing the value of Array[x] Of String[x] Is Not Working
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This short program will not compile

Code: Select all

program Constant_Array_Of_String;

{  MCU         : ATmega16                       
   Oscillator  : 10 MHz, External               
   SW          : mikroPascal for AVR 4.02 Full Version }

var
  Day   : String[3];
  Temp  : Byte;

const
  Day_Of_Week : array[1..7] of String[3] =
  ('Sun','Mon','Tue','Wed','Thu','Fri','Sat');

{ M A I N    P R O G R A M }
begin
  Temp := 0;

  for Temp := 1 to 7 do
    begin
      Day := Day_Of_Week[Temp];
    end;

end.
The error message I received is
0:17 E-9 Error in ASM code: Address is out of range "69" R17
Assigning the array of string as part of const is fine.
But when it hit the line 'Day := Day_Of_Week[Temp]', it complained.

Details:http://www.mikroe.com/forum/viewtopic.php?t=12315


--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[2] Bug in Adc_Read(0) with ATtinyxx
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This short program will not compile with any of the ATtiny series.

Code: Select all

program SLA_Charger;
{
  MCU          : ATtiny13
  Oscillator   : Internal, 9.6 MHz
  SW           : mikroPascal for AVR 4.02 Registered Version
  Date         : 23/10/07
}

Var
  Voltage : Integer;

begin
  Voltage := Adc_Read(0);     // read ADCB(0)
end.
The error message I received is
13:14 E-3 Identifier 'Adc_Read' was not declared SLA_Charger.apas
13:24 E-3 Identifier ')' was not declared SLA_Charger.apas
Yet if I use the ATmega8, it does compiled without any error.
Is there something I miss or is there a bug in the compiler ?
From the support team
Unfortunately, current compiler version doesn't support all ATtiny modules; ADC feature is not supported.
We will support it in next compiler release, but for now we can not say when will that be precisely.
Details: http://www.mikroe.com/forum/viewtopic.php?t=12080

Will the above be supported in the next version as these are quite common to use ATtiny chips with ADC facilities ?


--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Post Reply

Return to “mikroPascal for AVR General”