PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Dec 25, 2006 11:11 pm |
|
|
The program below uses the CCS #ID directive to put four 16-bit
words in the User ID locations in the HEX file.
The ICD2 then programs the ID locations when the PIC is programmed.
When the program is run, it calls the read_program_eeprom() function
and reads the User ID values.
The output of the program is shown below.
Note that the 16-bit values are stored in Intel lo-hi format by the #ID
directive. The program reads them back as individual bytes, so that's
why the pairs of bytes are reversed.
Quote: |
23 01 67 45 AB 89 EF CD
|
Code: |
#include <18F452.h>
#fuses XT, NOWDT, PUT, PROTECT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#ID 0x0123,0x4567,0x89AB,0xCDEF
// The following address comes from the Programming
// specification for the 18F452.
#define USER_ID_BASE_ADDR 0x200000L
//========================================
void main()
{
int8 i;
int8 result;
for(i=0; i < 8; i++)
{
result = read_program_eeprom(USER_ID_BASE_ADDR + i);
printf("%X ", result);
}
printf("\n\r");
while(1);
}
|
|
|