How to encrypt a PIC microcontroller

Source: Internet
Author: User

I have seen many beginners confuse reading and writing the ID codes of pic16 series single-chip microcomputer. To be honest, this information is not comprehensive. Some textbooks may involve the introduction of ID areas, but they often come from the first generation. This is a relatively easy place for beginners to make mistakes. Today, I am free to sort out related questions and share them with you. It may not be appropriate in some places. You are welcome to discuss more.


1. What is the id region?


The ID area is independent of the EEPROM, Flash, and ram areas. Programmers can use this area to store software version numbers, writing dates, burning dates, product identifiers, and other information. However, the pic16 series in this region can only store 4 bytes.


2. How to install the ID code in the ID area?


You can use the macro command idloc (x) provided by PICC. The procedure is as follows:


..................................... // Other macro definitions in the header file


_ Idloc (76f4); // note: the front is an underscore. The brackets can contain a maximum of 2 bytes.


Void main ()


{


...................................... // Program subject


 


}


Compile the program and then use the burning tool to burn it into the microcontroller. Please note that idloc (x) contains a maximum of two hexadecimal bytes. the excess part will be invalid. For example, if you write 987fe3, E3 will be lost. In addition, let's talk about how the two hexadecimal numbers are stored in the ID area. We already know that idloc (x) can contain another byte, while ID can contain four bytes. Take x = 76f4 as an example. These are 07060f04. That is to say, add 1 0 before each hexadecimal number. If you do not write a hexadecimal number of 2 bytes, for example, 78 of 1 byte. The compiler will add 0 in front, and it will become 0078. 00000708 is written to the ID area.


 


3. How can I read the ID code?


You can use the burning tool with the compiler. I use PICC and icd2. After the microcontroller is powered on, the read target device operation is executed in programming mode, and the ID memory under the configure menu


You can see the ID code set during programming.




In fact, most of the PIC does not have a unique ID. Some people enable Encryption by burning the PIC read-out bus, but the device needs to be self-made.
As long as it is a large number of chips sold in the market, decryption is not a headache. We can only try to use new models or uncommon models.

Some people use the EEPROM in the MCU, but it is not that simple. for mass production, some skills are needed to better solve this problem.
1. Set up a self-check program. through special operations (I have a self-made tool that can forcibly fix the related Io of the MCU on a certain logical electrical level, and the software determines the logical combination, you must comply with a specific combination to enter the Special Operation startup code. UART accepts the communication data of the tool, and transmits the communication data to the number and position of the eeprom to be erased ).
2. After Entering the self-check, the MCU will erase a specified position in the eeprom (increase the VCC voltage to accelerate the failure) and stop the operation after a maximum of 2 million write operations, generally, the number of times that an MCU comes with is less than 1 million times. A byte of the EEPROM is repeatedly erased between 0xaa and 0x55.
3. The wiping time is still relatively long. Generally, it takes more than ten minutes. I usually perform this self-check program in the product power-on aging stage (the product generally needs to be in the aging Room 4 ~ 6 hours of power-on aging time, self-check program is compatible with this time, to avoid new labor loss)
4. During the erase operation, the number of times when the EEPROM is invalid in Ram is recorded and included in other EEPROM bytes.
5. During normal product sales, the app user program is executed and the invalid byte is constantly erased. If the data cannot be erased, the encryption is successful. Otherwise, another error correction program will not be mentioned, you can find a solution on your own.


How to encrypt a PIC microcontroller

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.