17.02.2015 Views

CCS C Compiler Manual PCB / PCM / PCH

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Functional Overview<br />

Program Eeprom<br />

The Flash program memory is readable and writable in some chips and is just readable in<br />

some. These options lets the user read and write to the Flash program memory. These<br />

functions are only available in flash chips.<br />

Relevant Functions:<br />

read_program_eeprom(address)<br />

write_program_eeprom(address, value)<br />

erase_program_eeprom(address)<br />

Reads the program memory location (16 bit or 32 bit depending<br />

the device).<br />

Writes value to program memory location address.<br />

Erases FLASH_ERASE_SIZE bytes in program memory.<br />

write_program_memory(address,dataptr,count) Writes count bytes to program memory from dataptr to address.<br />

When address is a mutiple of FLASH_ERASE_SIZE an erase is<br />

performed.<br />

read_program_memory(address,dataptr,count) Read count bytes from program memory at address to dataptr.<br />

Relevant Preprocessor:<br />

#ROM address={list}<br />

#DEVICE(WRITE_EEPROM=ASYNC)<br />

Can be used to put program memory data into the hex file.<br />

Can be used with #DEVICE to prevent the write function from<br />

hanging. When this is used make sure the eeprom is not written<br />

inside and outside the ISR.<br />

Relevant Interrupts:<br />

INT_EEPROM<br />

Interrupt fires when eeprom write is complete.<br />

Relevant Include Files:<br />

None, all functions built-in<br />

Relevant getenv() parameters<br />

PROGRAM_MEMORY<br />

READ_PROGRAM<br />

FLASH_WRITE_SIZE<br />

FLASH_ERASE_SIZE<br />

Size of program memory<br />

Returns 1 if program memory can be read<br />

Smallest number of bytes written in flash<br />

Smallest number of bytes erased in flash<br />

Example Code:<br />

For 18F452 where the write size is 8 bytes and erase size is 64 bytes<br />

#rom 0xa00={1,2,3,4,5}<br />

//inserts this data into the hex file.<br />

erase_program_eeprom(0x1000);<br />

//erases 64 bytes strting at 0x1000<br />

write_program_eeprom(0x1000,0x1234); //writes 0x1234 to 0x1000<br />

61

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!