(XC16) How can I utilize the upper 8-bits of program memory to effectively store constants?
The qualifier __pack_upper_byte will allocate the message string into Flash memory in such a way that the upper byte of memory contains valid data. There are no restrictions on the types of __pack_upper_byte data. This qualifier can be used with both the primary data types as well as the secondary data types.
The compiler will "pack" structures as if __attribute__((packed)) had been specified.
Example
Memory Allocation Without __pack_upper_byte (string_un_packed):
Address | Value | ASCII |
---|---|---|
00A08 | BE054F BE044F 060000 006854 | O...O... ....Th.. |
00A10 | 007369 006920 002073 002061 | is.. i.. s ..a .. |
00A18 | 007473 006972 00676E 00002E | st..ri.. ng...... |
Memory Allocation With __pack_upper_byte (string_packed):
Address | Value | ASCII |
---|---|---|
00D30 | 696854 692073 612073 747320 | Thi.s i. s a. st. |
00D38 | 6E6972 002E67 FFFFFF FFFFFF | rin.g... ........ |