//----- CONSTANTS LOCATED IN PROGRAM MEMORY -----
#pragma romdata firm_upgrade_code_markers_romdata_section=0x0009fc
      const rom WORD firmware_upgrade_marker_1 = OUR_PRODUCT_ID;
      const rom WORD firmware_upgrade_marker_2 = OUR_FIRMWARE_REVISION;
#pragma code normal_section=0x000a00
extern void _startup (void);        // See c018i.c in your C18 compiler dir
#pragma code _RESET_INTERRUPT_VECTOR = 0x000a00
void _reset (void)
{
      _asm goto _startup _endasm
}
#pragma code

 

Using Program Memory For A Large Lookup Table



//Lookup value from our program memory lookup table
//dest is the index into the lookup table we want the word value for
	static DWORD_VAL address;
	address.val = 0x1fd00;					//<<<<<THE START ADDRESS IN PROG MEMORY
	address.val += dest;
	address.val += dest;

	TBLPTRU = address.v[2];
	TBLPTRH = address.v[1];
	TBLPTRL = address.v[0];

	_asm
	//tblrd*+
	TBLRDPOSTINC
	//dw	0xffff				//(Silicon Bug Fix)
	_endasm
	w_temp = TABLAT;

	_asm
	//tblrd*+
	TBLRDPOSTINC
	//dw	0xffff				//(Silicon Bug Fix)
	_endasm
	w_temp |= (WORD)TABLAT << 8;


//----- LOOKUP TABLE LOCATED IN PROGRAM MEMORY -----
//Have this at the end of a .c file if compiler gets upset
#pragma romdata firm_upgrade_code_markers_romdata_section=0x1fd00		//<<<<<THE START ADDRESS IN PROG MEMORY (REMEMBER THAT PIC18 INSTRUCTION ADDRESS ARE +2, USE LAST BLOCKS BEFORE CONFIG MEMORY)
const rom WORD led_lookup_table[]={
0	,
1	,
2	,
3	,
4	,
5	,
6	,
7	,
8	,
9	,
10	,
11	,
12	,
13	,
14	,
15	,
16	,
17	,
18	,
19	,
20	,
21	,
22	,
23	,
24	,
25	,
26	,
27	,
28	,
29	,
30	,
31	,
32	,
33	,
34	,
35	,
36	,
37	,
38	,
39	,
40	,
41	,
42	,
43	,
44	,
45	,
46	,
47	,
48	,
49	,
50	,
51	,
52	,
53	,
54	,
55	,
56	,
57	,
58	,
59	,
60	,
61	,
62	,
63	,
64	,
65	,
66	,
67	,
68	,
69	,
70	,
71	,
72	,
73	,
74	,
75	,
76	,
77	,
78	,
79	,
80	,
81	,
82	,
83	,
84	,
85	,
86	,
88	,
90	,
92	,
94	,
97	,
99	,
101	,
103	,
106	,
108	,
111	,
113	,
116	,
118	,
121	,
123	,
126	,
129	,
132	,
134	,
137	,
140	,
143	,
145	,
148	,
151	,
154	,
157	,
160	,
163	,
166	,
170	,
173	,
176	,
179	,
183	,
186	,
189	,
193	,
196	,
200	,
203	,
207	,
210	,
214	,
217	,
221	,
225	,
229	,
232	,
236	,
240	,
244	,
248	,
252	,
256	,
260	,
264	,
269	,
273	,
277	,
281	,
286	,
290	,
295	,
299	,
304	,
308	,
313	,
318	,
322	,
327	,
332	,
337	,
342	,
347	,
352	,
357	,
362	,
367	,
373	,
378	,
383	,
389	,
394	,
400	,
405	,
411	,
416	,
422	,
428	,
434	,
439	,
445	,
451	,
457	,
463	,
469	,
476	,
482	,
488	,
494	,
501	,
507	,
514	,
520	,
527	,
533	,
540	,
547	,
553	,
560	,
567	,
574	,
581	,
588	,
595	,
602	,
609	,
616	,
624	,
631	,
638	,
646	,
653	,
661	,
668	,
676	,
683	,
691	,
699	,
707	,
714	,
722	,
730	,
738	,
746	,
754	,
763	,
771	,
779	,
787	,
796	,
804	,
813	,
821	,
830	,
838	,
847	,
856	,
864	,
873	,
882	,
891	,
900	,
909	,
918	,
927	,
936	,
945	,
955	,
964	,
973	,
983	,
992	,
1002	,
1011	,
1021	,
1023
};
#pragma code

 

USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.

Comments

Your email address will not be published. Required fields are marked *