Programming 12F675
Created by: hgamal
I was trying to burn a 12f675 device. These devices reserves one word at the end of programming space to calibrate its internal clock. This word is calibrated by the factory before the device is been delivered to market. Its is very common to do not overwrite the original value.
The device definition, inside device.h, follows: { .name = "PIC12F675", .protocol_id = 0x63, .variant = 0x73, .read_buffer_size = 0x80, .write_buffer_size = 0x20, .code_memory_size = 0x7fe, .data_memory_size = 0x80, .data_memory2_size = 0x00, .chip_id = 0x00, .chip_id_bytes_count = 0x02, .opts1 = 0x00, .opts2 = 0x00, .opts3 = 0x40, .opts4 = 0x1102330, .package_details = 0x8000200, .write_unlock = 0x1ba, }
Although the device has 1024 words of code memory, the definition above declares only 1023 words (2046 bytes). I think it is done in order to preserve the original calibrated clock already set.
There are two problems on the above limit code approach:
-
the program does not work. It can not read or write data from the device. At line 146 of main.c the instruction: if(size % device->read_buffer_size != 0) { does not allow code odd aligned code - different from value specified device->read_buffer_size
-
if the code size would be set to the correct value 1024 words (which will be aligned to device->read_buffer_size), during normal device programming, a impatient user would overwrite the original factory value set. This behavior will force users to read this value and set it on its binary source file, before program the device.
My suggestion is create a memory map, for each device, specifying memory regions where the program must read from device before write the buffer to the device. Its a good idea create a option flag disabling this behavior.