PIC24 Program behavior ...

Discuss about beta versions of mikroPascal compiler.
Post Reply
Author
Message
yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

PIC24 Program behavior ...

#1 Post by yo2lio » 26 Jan 2008 13:09

Hello,

In MikroPascal for DSPIC, when variables of type record are declared in separate Unit, program behavior :

Code: Select all

unit unit_pt;

const
      CacheLength  : byte = 5;
      PingCacheLength  : byte = 5;

type IpHeader = array[4] of byte;
type MacHeader = array[6] of byte;

type TPingCache = Record
     IpP    : IpHeader;
     MacP   : MacHeader;
     Time  : word;
     UserTime  : word;
     T     : word;
     TTL   : byte;
     UserTTL : byte;
end;

type TArpCache = Record
     Valid : Boolean;
     tmr   : longint;
     Ip    : IpHeader;
     Mac   : MacHeader;
end;

type TNtp = Record
     Rfc   : dWord;
     Unix  : dWord;
     Year  : word;
     Month : byte;
     Day   : byte;
     Hour  : byte;
     Min   : byte;
     Sec   : byte;
     Str   : string[32];
end;

var
    ArpCache : array[CacheLength] of TArpCache;
    PingCache : array[PingCacheLength] of TPingCache;
    TTime : TNtp;
    
implementation
end. 

Code: Select all

program Test_Pt;

uses unit_pt;

procedure EraseArpCache;
var j,g : word;
begin
  j := 0;
  while j < CacheLength do
    begin
      g := 0;
      while g < 4 do
        begin
         ArpCache[j].Ip[g] := $FF;  // erase Ip Cache value
         inc(g);
        end;
        g := 0;
      while g < 6 do
        begin
         ArpCache[j].Mac[g] := $FF;  // erase Mac Cache value
         inc(g);
        end;
      ArpCache[j].Valid := False;
      ArpCache[j].Tmr := $FFFFFFFF;
      inc(j);
    end;
end;

procedure ErasePingCache;
var j,g : word;
begin
  j := 0;
  while j < PingCacheLength do
    begin
      g := 0;
      while g < 4 do
        begin
         PingCache[j].IpP[g] := 0;  // erase Ip Cache value
         inc(g);
        end;
        g := 0;
      while g < 6 do
        begin
         PingCache[j].MacP[g] := 0;  // erase Mac Cache value
         inc(g);
        end;
      PingCache[j].Time := 0;
      PingCache[j].UserTime := 0;
      PingCache[j].T := 0;
      PingCache[j].TTL := 0;
      PingCache[j].UserTTL := 0;
      inc(j);
    end;
end;

begin
  EraseArpCache;
  ErasePingCache;
  WordToStr(1000,TTime.Str);
end.
This problem was tested in simulator and real word MCU PIC24FJ128GA010.
Last edited by yo2lio on 28 Jan 2008 10:12, edited 2 times in total.
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

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

Re: PIC24 Program behavior ...

#2 Post by zristic » 28 Jan 2008 09:34

yo2lio wrote:In MikroPascal for DSPIC, when variables of type record are declared in separate Unit, program behavior :
You forget to finish the sentence... What happens with the program?

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

#3 Post by yo2lio » 28 Jan 2008 10:06

Sorry,

Behavior strange, I can run the program in simulator but result is not as expected and MCU go crazy.

This happened only if variables is declared record type.
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

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

#4 Post by zristic » 28 Jan 2008 10:25

I put this on the list, to be investigated and fixed if needed. Thanks.

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

#5 Post by yo2lio » 28 Jan 2008 10:36

Run this program in simulator and take a look at ArpCache[0].Tmr, must be $FFFFFFFF and is not .

Also at TTime.Str must be '1000' and is not.
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

Post Reply

Return to “mikroPascal Beta testing”