Hi, should you not use a "var" parameter for a port? By not doing so, you receive only a copy of the PortData, but you can not change it.
Example (for 8 bit PICs):
Code: Select all
var LCD1602Port, LCD1602Tris: ^byte;
...
procedure LCD1602Init(var LCDPrt: byte); // <------------- var parameter
// LCD initialization routine //
// Resets the LCD and initializes the LCD to 4 bit mode, 2 rows, cursor off
var I: byte;
begin
LCD1602Port := @LCDPrt;
{$IFDEF P16}
LCD1602Tris := LCD1602Port + 128;
{$ELSE}
LCD1602Tris := LCD1602Port + 18;
{$ENDIF}
...
LCDPrt := $20; // example of usage
LCD1602Port^ := $20; // example of usage, same as above
LCD1602Tris^ := 0; // example of usage
LCD1602Tris^.3 := 1; // example of usage
etc...
As you can see you can use the var parameter directly to get the port's value or to set it. One can also get the address of the port, simply using the "@" prefix (gives you a pointer to the address of the port).
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)