Storing constant data in program memory

From Mech
(Difference between revisions)
Jump to: navigation, search
(Original Assignment)

Revision as of 17:18, 28 January 2008

Contents

Original Assignment

Your PIC has a relatively large amount of program memory (32 Kbytes) but relatively little data memory (1536 bytes). For some applications, we want to have lookup tables or calibration data stored on our PIC, but we don't want it hogging data memory. This project is to demonstrate how to write a program that stores constant data in program memory. Test your ability to do this by creating a look-up table for the sin function. This is a 1-d array with integer index corresponding to an angle (e.g., numbers 0 to 89 if the index is in degrees; angles in other quadrants can be determined by simple transformations). Depending on your choice of int8, int16, or float to represent the number, what angle resolution can you use for the index before you reach the limits of program memory?

See p. 43 of the PIC MCU C Compiler book.

Finally, give sample code for storing data in the EEPROM, too.

Overview

Circuit

Code

Personal tools