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 support@ccsinfo.com

Serial num in EEPROM & FLASH
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
temtronic



Joined: 01 Jul 2010
Posts: 9097
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Dec 27, 2018 7:23 am     Reply with quote

Why not just use the #ROM preprocessor directive ? It's easy to use and works ! You've only got ONE PIC to put a serial number in......
If this was a production run of say 50-1000 pcs , then you should invest in hardware that will easily 'serialize'.
Jay
kmp84



Joined: 02 Feb 2010
Posts: 345

View user's profile Send private message

PostPosted: Thu Dec 27, 2018 8:07 am     Reply with quote

Hi mr."temtronic",

Yes, This is production with more than 1000 devices.
temtronic



Joined: 01 Jul 2010
Posts: 9097
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Dec 27, 2018 8:50 am     Reply with quote

The ICD-U64 is about $100USD, so for 1,000 units, just add 10 cents to each and the programmer is paid for !
If this isn't possible, you need to look at your business plan and costing for the product. When you price in R&D time at $50 an hour( 1/3 what I charge for POC designs) , 2hrs of time wasted trying to get the job done should have been invested in better tools( the hardware..the programmer unit).
All too often, some look at just the upfront cost ($100) and don't see the bigger picture of getting the product to market fast. Getting it to the clien 1 day sooner could save you $1000 easily, if not more.

Jay
kmp84



Joined: 02 Feb 2010
Posts: 345

View user's profile Send private message

PostPosted: Thu Dec 27, 2018 8:59 am     Reply with quote

Mr. "temtronic" I have ICD-U64 unit.
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Thu Dec 27, 2018 9:23 am     Reply with quote

kmp84 wrote:
Hello,
I want to ask you is it possible to use "#serialize" directive with mcu without eeprom? Also can be stored serial number with format like this: "ABCD0000001" and auto increment? (ABCD const string + string number)
Thanks!


Yes. The serial can be written to flash.

It only handles a number. However you could use the string option, and store the ABCD separately.
kmp84



Joined: 02 Feb 2010
Posts: 345

View user's profile Send private message

PostPosted: Thu Dec 27, 2018 10:09 am     Reply with quote

Hi mr.Ttelmah,

I have No idea how to do this with help info:

Code:
 
//Retrieves serial number from serials.txt

#serialize(id=serialNumA,listfile="serials.txt") 



And there is no example how to retrieve num from flash!
temtronic



Joined: 01 Jul 2010
Posts: 9097
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Dec 27, 2018 10:29 am     Reply with quote

While I've never used it..

from the CCS manual section #serialize..

//Place string serial number at EEPROM address 0, reserving 2 bytes

#serialize(dataee=0, string=2,next="AB",prompt="Put in Serial number")

It seems to me dataee is where the start of the 'serial number' begins.
You should be able to use the read_eeprom() function (check manual for proper syntax !) to retrieve the PICs serial number. Obviously you'll need to setup proper variables and be sure you don't save the serial number where it overwrites the program !!

Jay
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Dec 27, 2018 1:02 pm     Reply with quote

kmp84 wrote:

And there is no example how to retrieve num from flash!

CCS has the read_serial() function in the link below, which can read
the serial number from flash or eeprom:
http://www.ccsinfo.com/newsdesk_info.php?newsdesk_id=198
It reads the serial number and writes it into an int32 variable.
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Thu Dec 27, 2018 1:34 pm     Reply with quote

On reading the number from flash, you don't have to.

All you do is tell serialise the constant variable you want the number
to be put into, and this 'variable', will contain the number. You can use it
just like any other const variable. So there is no retirieval involved.

So in your code, declare a variable:

const int32 serial=0;

Then serialize with:

#serialize(id=serial,file="filename.txt")

'serial' will start with what is specified in 'filename.txt', and count up from
this.
kmp84



Joined: 02 Feb 2010
Posts: 345

View user's profile Send private message

PostPosted: Fri Dec 28, 2018 3:21 am     Reply with quote

Hi all,
Very useful directive. Programming speed with ICD U64 is little bit slower (connect, disconnect) but everythings work perfect!

Some example program:
Code:

#include <16F1459.h>
#device *=16
#fuses NOPROTECT,MCLR,PUT,NOWDT
#use delay(int=8MHz, clock=8MHz, act=USB)  //USB_FULL,

//#use RS232(DEBUGGER,rcv=PIN_B6,xmit=PIN_B6,stream=STREAM_MONITOR)
#use rs232(baud=9600, xmit=PIN_B7, rcv=PIN_B5, errors)

const char prefix_name[] = "ABCD";
const unsigned int32 serial=0;
#serialize(id=serial,file="serial_num.txt",log="log_file.txt")

void main (void){
   
   delay_ms(100);
   
   printf("\r\n Target Power-Up, Sn:%s%08lu", prefix_name, serial);
   
   for(;;){
     
       // user code;
   }
}


Thank You ALL and The Best Wishes!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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