In the past I had some problems regarding the address space of formal parameters within functions and procedures (I already wrote a ticket for this, and it really seems to be some sort of bug, a MikroE stuff member confirmed). For MikroPascal PRO for PIC and dsPIC setting the optimization level to 0 turned out to be a good solution. However, in mikroPascal PRO for FT90x, which I use to program my HMI 5'' Display, the function VTFT_GetExtData() can not be passed as function pointer to the External memory setup function FT812_Register_GetExtData() anymore, if the optimization level is set to 0. Here is the code bock of how the function is implemented (I copied from the hardware pattern "MIkromedia_HMI_5_RTP" (this goes for the other VTFT-Settings as well) and yes, I use external resource storage functionallity ):
Code: Select all
function VTFT_GetExtData(fPos : dword; bytesToGet : dword; pBytesGot : ^dword): ^byte;
var scOffset : word;
begin
pBytesGot^ := 0;
if (rfHandle < 0) then begin
result := 0; // return with nil if handle was bad.
exit;
end;
// We will utilize some of the fat32 implied features
// (such as built in sector buffer) to reduce ram memory consumpiton.
// You can't use this approach if this buffer is going to be used
// from another thread (i.e. using fat32 routines in interrupt...)
// In that case or if you have plenty of ram memory use separate
// as large as possible data buffer.
f32_sector.fSectNum := rfStartSect + fPos div 512;
Mmc_Read_Sector(f32_sector.fSectNum, f32_sector.fSect);
// 512 bytes sector buffer implied.
scOffset := fPos mod 512;
if(bytesToGet > 512-scOffset) then
pBytesGot^ := 512-scOffset
else
pBytesGot^ := bytesToGet;
result := @f32_sector.fSect + scOffset;
end;
16415 373 Incompatible function pointers (function prototypes do not match): R0 vs ?T3665 HMI_ZMB_301_v0_driver.mpas
for this line in InitVTFTStack():
Code: Select all
...
// External memory setup // [line: 16414 ]
FT812_Register_GetExtData(@VTFT_GetExtData); // [line: 16415 ]
...
Can someone pleaes explain or confirm this? Is this piece of code still up-to-date or is there any better implementation?
Thank you,
Micha