PIC18 libraries replacements - package updated to v 1.12

General discussion on mikroPascal PRO for PIC.
Author
Message
janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

PIC18 libraries replacements - package updated to v 1.12

#1 Post by janni » 29 Sep 2009 16:58

The replacement libs are being updated continually and there's a web page about them (among other things). Please look for news there or at Libstock.
_____________________________________________________________________
For the incoming version 3.00 of mP PRO I've prepared some refreshed and some new replacement libraries:

- Strings library (__Lib_String)
- Conversions library (__Lib_Conversions)
- Floating-point math library (__Lib_MathDouble - two versions)
- internal EEPROM library (__Lib_EEPROM_256 and __Lib_EEPROM_1024)
- System library (__Lib_System)


These are all precompiled libs replacing official ones with the advantage of smaller and faster code for routines present in official libs, and many additional routines that should simplify programming and make it more :wink: Pascal/Delphi-like. Hope you'll like them :) .

In the Conversions lib replacement some routines perform similar task - that's because new routines work differently than those from official lib (in fact, the latter call the former and only then change the result). The official lib routines are there both for compatibility with older code and for other official libs that use them.

The Strings library has been expanded with new Delphi-like routines. For those that use Florin's Ethernet libs a small library was added that should be used instead of his Additional Strings Library (which cannot be used in parallel with the Conversions lib replacement). It contains just few routines that differ in naming from the Strings lib replacement and are needed by Ethernet libs. It's naturally called the same: pic_additional_string_library.mcl

Floating-point math library replacement has two versions - both produce smaller code than the official one and give more accurate calculation results by fixing problems that the official lib inherited from the original Microchip library, i.e.
- lack of 'unbiased' rounding,
- lack of rounding while converting to integer types,
- lack of big numbers 'rounding', i.e. conversion error reduction,
- max negative number reported as integer overflow,
- overflow not reported for division by zero (result=dividend),
– no protection against numbers with EXP=0 and significand<>0 that do not belong to Microchip format.

Both versions give access to floating-point operations' status byte. One of them may generate 'exceptions', i.e. allows to write code that contains provisions for calculation errors (like overflow, underflow, or division by zero).
There is also an additional lib, called FPmath, containing some useful routines. Some of them are replacements of official ones that either won't work properly with the new lib, or are less optimised. There are also conversion routines, between Microchip and IEEE 754 formats.

Internal EEPROM libraries contain some additional routines for block read/write.

The System lib replacement is aimed at demanding applications and for use by a bit more advanced programmers. Besides some marginal optimisation, the main change introduced concerns only indirect function calls, i.e. calls made using pointers. The original library uses Top Of Stack registers in such cases – which in turn requires blocking of interrupts for several assembly instructions. If this is undesirable, indirect function calls may be performed using PCLAT rather than TOS - and without the need to block interrupts.

Every lib has a description in pdf format (cost me some time and determination to write them, so please do be merciful in criticising them :wink: ).

Archived file with all replacement libs may be accessed here: http://www.cobir.com/mPPROrepl.rar.

Please remember to save the official libs, or rename them before placing the replacement libs in the .../Uses/P18 directory.

About later updates read here and here.
Last edited by janni on 31 Oct 2019 21:49, edited 14 times in total.

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

#2 Post by Dany » 01 Oct 2009 19:58

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)

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

#3 Post by Dany » 02 Oct 2009 11:01

Hi Janni,

When I use the new "Conversions" and the modified "pic_additional_string_library" then my ethernet applications do not work any more: There is no more incoming data in routine "Eth_UserUDP" (I use your ENC libraries).

Thanks in advance! :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)

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

#4 Post by Dany » 02 Oct 2009 14:13

Erratum :oops: : I use the ENC libraries of Florin.
Dany wrote:(I use your ENC libraries).
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)

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

#5 Post by janni » 02 Oct 2009 15:06

I'm sure everybody knows who's the author of the ENC libs :) . Back to the problem - maybe Florin introduced some changes in his library. My version of pic_additional_string_library contains folowing routines

Code: Select all

procedure Mem_Set(pt:word; ch:char; n: word);

function Mem_Cmp(pt1,pt2:word; n: word): byte;

procedure Mem_Cpy(pt1,pt2:word; n: word);

procedure Str_Cut_Left(var str_: string[$FFF]; n: word);
which previously worked. We will have to wait for Florin to enlighten us about any changes in, naturally :wink: , his libs.

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

#6 Post by Dany » 02 Oct 2009 16:44

Thanks Janni.

I assume the reason for the problem can, besides in the adapted "pic addtional string library", also be in the new "Conversions" lib, as I understand that a lot of routines previously present in "pic addtional string library" are moved (and perhaps redesigned?) to the new "Conversions"?

Thanks in advance! :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)

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

#7 Post by yo2lio » 02 Oct 2009 17:17

hmmm,

I don't change anything in ETH library.

Dany, can you tell me if with old replacement library works ?

PS: I update my additional libraries. New version of SDMMC_SPI library available.
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

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

#8 Post by janni » 02 Oct 2009 17:36

Danny wrote:as I understand that a lot of routines previously present in "pic addtional string library" are moved (and perhaps redesigned?) to the new "Conversions"?

No, no routines previously present in my version of "pic addtional string library" were moved to Conversions lib (only routines, previously present in conversions2 lib, were moved to Conversions). I'll re-check if there are any discrepancies between Florin's routines and mine from Conversions and String libs that could lead to problems.
yo2lio wrote:I don't change anything in ETH library.
Danny previously used the 3.5 version of the ENC libs and it did work with my older replacement libs. If you also didn't make any changes to the pic_addtional_string_library then I'll have to look for them in my libs...

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

#9 Post by Dany » 02 Oct 2009 19:53

janni wrote:Danny previously used the 3.5 version of the ENC libs and it did work with my older replacement libs. If you also didn't make any changes to the pic_addtional_string_library then I'll have to look for them in my libs...
I still do use this version of the ENC libs.
The only replacement lib I used in the past was the String lib.
I tried to use the previous Conversion lib replacement together with the previous replacement version of Pic additional strings, but then I got some wierd linking errors, so that combination did not work.

With the appearance of the replacement libs suited for mP v3.00 I tried again to use them, with the known result.

So, at this moment I can use all replacement libs, except for the Conversions lib, together with the yo2lio's original Pic additional string library. ETH works flawless.

Using the new Conversions library with the adapted Pic additional strings lib gives me the ETH problem.
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)

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

#10 Post by janni » 02 Oct 2009 22:29

Dany wrote:I tried to use the previous Conversion lib replacement together with the previous replacement version of Pic additional strings, but then I got some wierd linking errors, so that combination did not work.
O.K. I've got the impression that both libs worked with the Ethernet libs or I would have tried to find a solution. Anyway, after communication with Florin (thanks again for quick response, Florin :) ), I think I know where the incompatibilities lay - there will surely be a way to solve this issue soon :) .

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

#11 Post by piort » 03 Oct 2009 02:51

hi gang,

Maybe nobody do it in the past but like many user of this forum, i use one (or many) of your lib or work... So i want to thank's you for all your good and nice work with MP ...

Thank Janni !
Thank Yo2lio !
Thank Dany !

you keep this forum alive and push Me do to a better compiler ;-)

its my 2 cents )))

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

#12 Post by Dany » 06 Oct 2009 10:31

Hi Janni,

Is the call to "SaveAll" in main and interrupt necessary when using your libraries? see http://www.mikroe.com/forum/viewtopic.p ... 0&start=21

Thanks in advance! :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)

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

#13 Post by janni » 06 Oct 2009 11:58

Thanks to Florin's and Dany's help, the incompatibility problems of Conversions lib with Florin's Ethernet libs have been solved :) . The libs have been updated.
Dany wrote:Is the call to "SaveAll" in main and interrupt necessary when using your libraries?
It's not always necessary, but it's better to do it. As Florin explained, with no explicit use of FSRs (in Pascal) in interrupt service routines, it's not needed. If one uses FSRs in Pascal code placed in ISRs (or calls routines that do it), it's better to call SaveAll both in ISR and main code.

Although I use much more assembly than Florin in his additional string lib, there are still many routines that use assignments to FSRs in Pascal. (This will be changed, if mE won't fix in v 3.00 release the problem with context saving for FSRs used in Pascal . Even so, it'll still be necessary sometimes to call SaveAll in ISRs, I'm affraid.)

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

#14 Post by Dany » 28 Oct 2009 11:28

Hi Janni,

I did set (accidently) the "BuildType" to "ICD Debug" and, when compiling, I got the error "error: 0 340 File 'C:\Program Files\Mikroelektronika\mikroPascal PRO for PIC\uses\P18\__Lib_String.mpas' not found" for all your replacement libraries I used. The error disappeared when I place the original libraries mE in 'uses\P18'.
This is only for your information, I do not need the ICD build type possibility.

But: your libraries are superb! Thanks :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)

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

#15 Post by janni » 28 Oct 2009 16:30

Yes, indeed :( . Apparently it's required to compile libs with ICD Debug, not Release option checked.

Newly compiled libs are available now (it appears that v 3.20 produces larger mcl files than the pre-release version, but it doesn't seem to be caused by larger final code).

Post Reply

Return to “mikroPascal PRO for PIC General”