CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Reading Serial ID EEProm Locations in 18f4550

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
foodwatch



Joined: 18 Apr 2006
Posts: 66

View user's profile Send private message Yahoo Messenger

Reading Serial ID EEProm Locations in 18f4550
PostPosted: Mon Dec 25, 2006 2:31 pm     Reply with quote

I seem to remember there was some kinda trick to allow reading the internal eeprom's 4 id locations. I want to be able to automatically increment serial numbers from a file as new chips are programmed with pcw/ICDU40 and then be able to read them as a 16bit int from within the program. Anyone done this before? Happy Holidays to all....
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Dec 25, 2006 11:11 pm     Reply with quote

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);
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group