Additional library for MikroPascal PRO 2009

General discussion on mikroPascal PRO for PIC.
Author
Message
yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

Re: Additional library for MikroPascal PRO 2011

#74 Post by yo2lio » 20 Mar 2011 14:51

New version available.

Additional library for MikroPascal PRO 2011 are available here :
http://www.microelemente.ro/MikroPascal ... y_V1_5.zip

All libraries recompiled with MP 4.60, debug mode.

Added ENC28J60 TCP/IP stack library for SPI2.
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

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: Additional library for MikroPascal PRO 2011

#75 Post by Dany » 20 Mar 2011 19:33

yo2lio wrote:New version available.

Additional library for MikroPascal PRO 2011 are available here :
http://www.microelemente.ro/MikroPascal ... y_V1_5.zip

All libraries recompiled with MP 4.60, debug mode.

Added ENC28J60 TCP/IP stack library for SPI2.
Thanks Florin! :D :D
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Paracom
Posts: 33
Joined: 11 Sep 2007 21:15
Location: Shropshire, United Kingdom

Re: Additional library for MikroPascal PRO 2009

#76 Post by Paracom » 22 Mar 2011 15:59

Thank You Florin,

I appreciate the time you have given to the community.

PS. Could I be cheeky and ask about UDP bootloader for MP Pro for 18f87j60.
your Zabbix bootloader libraries don't seem to cover the 18f87j60.

Thanks again.

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

Re: Additional library for MikroPascal PRO 2009

#77 Post by yo2lio » 22 Mar 2011 16:44

Hi,

I made some changes in bootloader... You can find UDP bootloader here: http://www.microelemente.ro/MikroPascal ... xample.zip
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

juanelectro
Posts: 47
Joined: 24 Oct 2009 16:01
Location: Colombia

Re: Additional library for MikroPascal PRO 2009

#78 Post by juanelectro » 26 Mar 2011 15:19

Good day,

In the past:
juanelectro wrote:Good day,

I send information from my own board to a server and sometimes board doesn't ping and it is necessary to reset it and connection comes back, it would be good to resolve problem in both situations (link up and down).


Thanks for attention.
somebody can resolve my question?


Thanks

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: Additional library for MikroPascal PRO 2009

#79 Post by Dany » 29 Mar 2011 16:50

Ref: http://www.mikroe.com/forum/viewtopic.p ... 0&start=39

Hi all, the SDMMC_SPIx.mpas routine published in above link can be extended with routines to extract the "CSD" and the "CID" of the SD/MMC card.
The CSD can e.g. be used to calculate the raw disk capacity, the CID to identify the manufacturer etc...

Florin will publish a version of SDMMC_SPIx with the CID/CSD routines are included. Thanks in advance Florin!


Here are the additional routines for SDMMC_SPIx:

Code: Select all

function SDMMC_Read_Csd(var data_for_registers: array[16] of byte): byte;
function SDMMC_Read_Cid(var data_for_registers: array[16] of byte): byte;

Code: Select all

function SDMMC_read_cid_csd(var data_for_registers: array[16] of byte; csd_: boolean): byte;
var Index : Word;
    TimeOut : Byte;
    Cmd: byte;
begin
  Result := 1;                           // error
  if cardtype = 0 then exit;             // no card

  if csd_
  then Cmd := CMD9                       // Send CSD
  else Cmd := CMD10;                     // Send CID

  TimeOut := 0;
  
  while result = 1 do
  begin
    SDMMC_CS := 0;                       // select card
    nop;
    nop;
    if SendCmd(Cmd, 0) = $00 then        // Send Cmd "send CSD/CID"
    if SeekResponse($FE) = $FE then      // Read start token
    begin
      Index := 0;
      FSR2 := word(@data_for_registers);
      while Index < 16 do                // Read data block, 16 bytes
      begin
        SDMMC_Read;                      // Result = in R18
        POSTINC2 := R18;
        Inc(Index);
      end;
      SDMMC_Read;                        // Read dummy CRC to conclude data block
      SDMMC_Read;
      result := 0;                       // Read completed successfully
    end;
    SDMMC_CS := 1;                       // de-select card
    nop;
    nop;
    SDMMC_Read;                          // Clock SD/MMC to complete read
    if Inc(TimeOut) > 1 then break;      // 2 tries
  end;
end;

function SDMMC_Read_Csd(var data_for_registers: array[16] of byte): byte;
begin
  Result :=  SDMMC_read_cid_csd(data_for_registers, true);
end;

function SDMMC_Read_Cid(var data_for_registers: array[16] of byte): byte;
begin
  Result :=  SDMMC_read_cid_csd(data_for_registers, false);
end;


Things that can be done with the CID/CSD:

Code: Select all

procedure SDMMC_CID_CSD_mirror(var dat: array[16] of byte);
// mirrors the 16 byte array: the MSB is in position 0 (was read in first)
var I, Tmp: byte;
begin
  for I := 0 to 7 do
  begin
    Tmp := Dat[I];
    Dat[I] := Dat[15-I];
    Dat[15-I] := Tmp;
  end;
end;

function SDMMC_CardSize: DWord;
// Returns the raw size of the card in bytes
// Doc: http://www.sdcard.org/developers/tech/sdcard/pls/simplified_specs/Part_1_Physical_Layer_Simplified_Specification_Ver3.01_Final_100518.pdf
var Dat: array[16] of byte;
    I, error: byte;
    Csd_Struct, C_size_mult, Read_Bl_Len: byte;
    C_size: Dword;
begin
  Result := 0;
  error := SDMMC_Read_Csd(Dat);

  if error = 0 then
  begin

    //mirror the data array: the MSB was read in first, we want it otherwise for Get_Bits
    SDMMC_CID_CSD_mirror(Dat);

    Csd_Struct := Get_Bits(Dat, 126, 127);
    if Csd_Struct = 0 then
    begin
      C_Size      := Get_Bits(Dat, 62, 73);
      C_Size_Mult := Get_Bits(Dat, 47, 49);
      Read_Bl_Len := Get_Bits(Dat, 80, 83);
      Result      := (C_Size + 1) * ( 1 shl (c_Size_mult + 2)) * (1 shl Read_Bl_Len);
    end
    else
    if Csd_Struct = 1 then
    begin
      C_Size := Get_Bits(Dat, 48, 69);
      Result := (C_Size + 1) * 512 * 1024;
    end;
  end;
end;

procedure SDMMC_ProductName(var S: string[5]);
var Dat: array[16] of byte;
    error, I1, I2: byte;
begin
  S := '';
  error :=  SDMMC_Read_Cid(Dat);
  if error = 0 then
  begin
    I2 := 3; //start with byte 3 of the Cid
    for I1 := 0 to 4 do // a 5 char string
    begin
      S[I1] := Dat[I2];
      inc(I2);
    end;
    S[5] := 0;
  end;
end;

procedure SDMMC_ProductRevision(var S: string[3]);
var Dat: array[16] of byte;
    error, Prv, Tmp: byte;
begin
  S := '';
  error :=  SDMMC_Read_Cid(Dat);
  if error = 0 then
  begin
    Prv := Dat[8]; // get the product revision (bcd number)

    Tmp := Prv shr 4; // get high order nibble
    Tmp := Tmp + 48;  // make it ascii
    S[0] := Tmp;

    Tmp := Prv and $0f; // get low order nibble
    Tmp := Tmp + 48;    // make it ascii
    S[2] := Tmp;

    S[1] := '.';
    S[3] := 0;
  end;
end;

function SDMMC_ProductSerialNumber: DWord;
var Dat: array[16] of byte;
    error: byte;
begin
  Result := 0;
  error := SDMMC_Read_Cid(Dat);
  if error = 0 then
  begin
    SDMMC_CID_CSD_mirror(Dat);

    Result := Get_Bits(Dat, 24, 55);
  end;
end;

procedure SDMMC_ProductManufacturingDate(var S: string[7]);
// returns the manufacturing date in format mm/yyyy
var Dat: array[16] of byte;
    error: byte;
    Mo: byte;
    Yr: word;
    TmpS: string[5];
begin
  S := '';
  error :=  SDMMC_Read_Cid(Dat);
  if error = 0 then
  begin
    SDMMC_CID_CSD_mirror(Dat);

    Mo := Get_Bits(Dat, 8, 11);
    Yr := Get_Bits(Dat, 12,19);
    Yr := Yr + 2000;

    ByteToStr(Mo, TmpS);
    trim(TmpS);
    StrCat(S, TmpS);

    WordToStr(Yr, TmpS);
    Trim(TmpS);
    StrCat(S, '/');
    StrCat(S, TmpS);
  end;
end;
Above code uses the unit "BitUtils" (http://www.rosseeld.be/DRO/PIC/index.htm#BitUtils) to fetch bitgroups out of the CSD/CID.

Enjoy!
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

CSL
Posts: 3
Joined: 04 Mar 2011 23:28

Re: Additional library for MikroPascal PRO 2009

#80 Post by CSL » 04 Jul 2011 14:42

We used yo2lio's ENC library in order to send TCP request to our server. We succeeded when we send request via port 80, but we couldn't reach our Java application which works with port 8080. We managed to open port 8080 and establish connection via port 8080 on both sides, but result of function Send_TCP via port 8080 is always false. Same procedure works perfect with port 80, we manage to get response from the server. Also Java application is responding when we send request to port 8080 from local computer.

Any ideas?

Bet regards
Uros Pesovic

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

Re: Additional library for MikroPascal PRO 2009

#81 Post by yo2lio » 20 Jul 2011 14:47

Hi,

I updated the libraries.

I made small changes in Ethernet libraries and it's strongly recommended to update this...

MP4.60 : http://www.microelemente.ro/MikroPascal ... y_V1_5.rar

MP5.00 : http://www.microelemente.ro/MikroPascal ... y_V1_6.rar
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

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: Additional library for MikroPascal PRO 2009

#82 Post by Dany » 20 Jul 2011 19:07

yo2lio wrote:Hi,

I updated the libraries.

I made small changes in Ethernet libraries and it's strongly recommended to update this...

MP4.60 : http://www.microelemente.ro/MikroPascal ... y_V1_5.rar

MP5.00 : http://www.microelemente.ro/MikroPascal ... y_V1_6.rar
Thanks! :D :D
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

aldis
Posts: 27
Joined: 17 Dec 2009 08:17

Re: Additional library for MikroPascal PRO 2009

#83 Post by aldis » 24 Jul 2011 11:12

Hello Florin

Thanks for the new libraries.
Unfortunately I can not find the MP5.00 Version on your homepage

Erwin

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

Re: Additional library for MikroPascal PRO 2009

#84 Post by yo2lio » 01 Aug 2011 09:16

aldis wrote:Hello Florin

Thanks for the new libraries.
Unfortunately I can not find the MP5.00 Version on your homepage

Erwin
Solved.
Sorry for trouble...
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

aldis
Posts: 27
Joined: 17 Dec 2009 08:17

Re: Additional library for MikroPascal PRO 2009

#85 Post by aldis » 01 Aug 2011 11:28

Thanks :D :D

Tuxmezoo
Posts: 156
Joined: 28 Jun 2011 11:21

Re: Additional library for MikroPascal PRO 2009

#86 Post by Tuxmezoo » 04 Mar 2012 21:47

Hi there. Just a dumb question. Im using Mikrobasic and the libaries i found on the site from YO2LIO are written in Pascal. Are there any way that these libraries are available in Basic or compiled as stand alone files and not running with an installer? I find them (The once i could use) very usefull but some lib's are not there. Only in the compiled version with installer and i don't have mikroPascal only mikroBasic.

ArtisticSoul
Posts: 8
Joined: 15 Oct 2009 14:26

Re: Additional library for MikroPascal PRO 2009

#87 Post by ArtisticSoul » 17 Oct 2013 09:59

Hello everyone,
I have problem with UDP bootloader. I just can't make it work. Can someone please help me.
I have mikroPascal PRO v4.60 (this is unfortunately only older version I could find, because with version 6.0.0 I had compile issues). Also, I have downloaded: http://www.microelemente.ro/MikroPascal ... y_V1_5.rar and http://www.microelemente.ro/MikroPascal ... xample.zip

After installing mP v4.6 I can compile entire project (UDP Bootloader V7 ZABBIX) without errors, but I can't ping my board. My board has PIC18F86J60 MCU with 25MHz OSC. Unfortunately I can't debug it with mP because it's homemade. Problem should't be in board itself because I have thoroughly tested it and I have mC HTTP Demo running on it without any problems. Using wireshark I have determined that my board with UDP bootloader doesn't respond to ARP requests.

P.S.
I tested it booth with 1 and also with 0 on RB6.
Also, I would like to mention that I haven't change anything in code except MCU.

CFG:
<?xml version="1.0"?>
<MCU_DEVICE_FLAGS>
<DEVICE>
<DEVICE_NAME>P18F86J60</DEVICE_NAME>
<VALUE>
<COUNT>6</COUNT>
<VALUE0>
<VAL>$00FFF8:$00A0</VAL>
</VALUE0>
<VALUE1>
<VAL>$00FFF9:$0004</VAL>
</VALUE1>
<VALUE2>
<VAL>$00FFFA:$00C5</VAL>
</VALUE2>
<VALUE3>
<VAL>$00FFFB:$000A</VAL>
</VALUE3>
<VALUE4>
<VAL>$00FFFC:$00F8</VAL>
</VALUE4>
<VALUE5>
<VAL>$00FFFD:$0007</VAL>
</VALUE5>
</VALUE>
</DEVICE>
</MCU_DEVICE_FLAGS>


MPPPI:
[DEVICE]
Name=P18F86J60
Clock=41666667
[MEMORY_MODEL]
Value=0
[BUILD_TYPE]
Value=0
[ACTIVE_TAB]
Value=UDP_Bootload_V7_ZABBIX.mpas
[USE_EEPROM]
Value=0
[EEPROM_DEFINITION]
Value=
[FILES]
Count=1
File0=UDP_Bootload_V7_ZABBIX.mpas
[BINARIES]
Count=0
[IMAGES]
Count=0
ActiveImageIndex=-1
[OPENED_FILES]
Count=1
File0=UDP_Bootload_V7_ZABBIX.mpas
[EEPROM]
Count=0
[ACTIVE_COMMENTS_FILES]
Count=0
[OTHER_FILES]
Count=0
[SEARCH_PATH]
Count=3
Path0=C:\Program Files\Mikroelektronika\mikroPascal PRO for PIC\Defs\
Path1=C:\Program Files\Mikroelektronika\mikroPascal PRO for PIC\uses\P18\
Path2=C:\Documents and Settings\Admin87\Desktop\MikroPascal_PRO_PIC_Example\UDP_Bootloader_PIC\
[HEADER_PATH]
Count=0
[HEADERS]
Count=0
[PLDS]
Count=0
[Useses]
Count=0
[EXPANDED NODES]
Node1=Sources
Node2=Output Files
Count=2

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: Additional library for MikroPascal PRO 2009 [solved]

#88 Post by Dany » 09 Jul 2014 18:58

Edited 2014-07-22: Solved somehow: build my project with mP version 5.00, and after that it was comilable again with v6.40. I found no explanation...

------------------
yo2lio wrote:I updated the libraries.

I made small changes in Ethernet libraries and it's strongly recommended to update this...

MP4.60 : http://www.microelemente.ro/MikroPascal ... y_V1_5.rar

MP5.00 : http://www.microelemente.ro/MikroPascal ... y_V1_6.rar
Hi Florin, I have some strange problems when I try to use v1_6 (which was for for mP5.00) together with mP v6.4.0. I get an error as shown below:
...
diagnostics: 0 134 Compiled Successfully C:\PIC Projects PRO compiler\Projects\ETH File Server Fat32\ETH_File_Server_Fat32.mpas
diagnostics: 0 139 All files Compiled in 16 ms
error: 0 304 object file name [HTTP_Server.mcl] does not match source file name [] object file name [HTTP_Server.mcl] does not match source file name []
error: 0 453 Unsuccessful linking 'ETH_File_Server_Fat32.mpppi' Unsuccessful linking 'ETH_File_Server_Fat32.mpppi'
The .mcl filename above is not one of the ENC28J60 files, but is only present if I add "lib1_enc28j60_v3_5.mcl" or "lib1_enc28j60_v3_5.mcl" to a uses clause in one of my units. If I do not add those libs in my uses clauses I get some "not defined" errors (e.g. for "socket").

Would it be possible for you to generate a version of both .mcl files with the v6.4.0 mP compiler?

Thanks in advance! :D :D
Last edited by Dany on 22 Jul 2014 21:42, edited 1 time in total.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Post Reply

Return to “mikroPascal PRO for PIC General”