PIC32 Plugin

C Plug-Ins

plugin ccall()
ccall#()
ccall&()
 

C plug-in's go a long way to addressing the problem that all interpreted languages have and that is one of speed. By using this mechanism it is hoped that this problem can be addressed. A further advantage is that it can enable none C programmers to perhaps try some C routines for themselves. The idea is that a compiled C function is saved to Flash and then called from Basic using the special call staements.

There is a full article on using plu-in's and so this section will confine itself to the keywords and keep the explanation to a minimum.

plugin
plugin to <page>
plugin from "filename" to <page>

plugin to 0
plugin from "remote.bin" to 6

This statement writes binary information to the flash memory. In the first example xmodem transfer is used and in the second example a file on the SD card is used. In both cases the file is written to Flash at a particular page. Each page is 4096 bytes and a plug-in will be compiled for a particular page or pages.

Page 0 is given by the system constant SYS_FLASH_END and all subsequent pages are calculated form this, for further information see the article mentioned above.

ccall() ccall#() ccall$()
ccall (<address>,<parameters>,...)

ccall(0x9d05c010, a int, s$ string)

This statement is used to call a C function the first part of the call must be the exact address of the function which will be found after compiling the C code. The following parameters are values that can be passed into the C function. The type of the parameter must be specified first followed by its value or variable.

Specifier Type
char single byte
string This must be a variable **
int 32 bit
unsigned 32 bit
float Floating point value (a#)

The above table shows the available type specifies, these must come first followed by the value. Constant values (for example int 12) can be used for all specifies except strings. This must be a variable. For example string "fred" will produce undefined results. The statement ccall will always return a value which can be ignored if required. Ccall will return an integer, ccall#() a float and ccall$() a string.