cpik C compiler for PIC c -18 devices Version 0.6.0 - PiKdev, An IDE ...
cpik C compiler for PIC c -18 devices Version 0.6.0 - PiKdev, An IDE ...
cpik C compiler for PIC c -18 devices Version 0.6.0 - PiKdev, An IDE ...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
{<br />
}<br />
int k ;<br />
PREPARE_ROM_ACCESS ; READ_ROMWORD ;<br />
<strong>for</strong>( k = prodl ; k ; --k)<br />
{<br />
READ_ROMWORD ;<br />
outdec(prodhl) ; putchar(’ ’ ) ;<br />
}<br />
FINISH_ROM_ACCESS ;<br />
This function is very simple to use:<br />
RIputwords("3, 1000, 2000, 3000") ;<br />
Please note that despite the parameter of RIputwords() is a literal, the data really stored in ROM<br />
are words (not a string of chars).<br />
7.7.3 Passing ROM data to a subroutine with a pointer to ROM<br />
In the previous section, blocks of data in ROM were anonymous.<br />
The ROM_ENTRY() macro allows to attach an identifier to a location in ROM as following:<br />
ROM_ENTRY(hello)<br />
{<br />
ROM_TXT("hello guys !\0") ;<br />
}<br />
The hello identifier has the type ROMptr and can be passed to any routine recieving this kind<br />
of pointer. For example, the void lcd_Rputs(ROMptr) ; (from the LCD library) allows such an<br />
usage.<br />
void f()<br />
{<br />
lcd_Rputs(hello) ; // displays ≪hello guy !≫<br />
}<br />
As previously, it is easy to write such a code at C level. For that purpose, the rom.h header<br />
provides a macro ROM_POINTER that allows to declare that a ROMptr will be used to access ROM.<br />
For example, suppose we want to implement a new version of puts() that access the character to<br />
be printed from a ROM pointer.<br />
void Rputs(ROMptr p)<br />
{<br />
ROM_POINTER(p) ;<br />
READ_ROMBYTE ;<br />
while( prodl )<br />
{<br />
putchar( prodl ) ; READ_ROMBYTE ;<br />
}<br />
}<br />
Not really complex, isn’t it ? But the next way to access ROM is even more simple, and more<br />
powerful.<br />
<strong>18</strong>