The write will not initiate if the above sequence is not exactly followed (write 55h to EECON2,
write AAh to EECON2, then set WR bit) for each byte. We strongly recommend that interrupts be
disabled during this code segment.
bcf STATUS, RP0
movlw 0x03
movlw EEADR
movlw 1
movwf EEDATA
bsf STATUS, RP0
bsf EECON1, WREN
bcf INTCON, GIE
movlw H'55'
movwf EECON2
movlw H'AA'
movwf EECON2
bsf EECON1, WR
bsf INTCON, GIE
;---
bsf STATUS, RP0
movf EEDATA, W
subwf EEDATA, W
btfss STATUS, Z
goto write_err
the whole code is here **broken link removed**
While writing to the eeprom write_err never got called, but if I try to read the eeprom with the programmator (K8048) the eeprom is filled with FFs.
The read procedure get the same, just FFs.
Can you help me to figure out what I am doing wrong?
It can be bad to write to EEPROM in the ISR if it occurs often as there is a limit of about 1,000,000 writes in the life of many pics.
If you do write in the ISR then you need to calculate how long the chip will last.
Can I read or write to the EEPROM using similar method of indirect addressing, such as:
Code:
For writing to the eeprom, you have to use the recommended code methods to ensure that it writes properly. This involves using the special write sequence and waiting for write completion before doing another write.
If you don't follow this then it won't work.
For reading, your code will not work because you have to set a read flag
BSF EECON1,RD
This is in bank 3 and is automatically reset after each read.
This applies to 16F types. If you are using 18F types then there are extra commands to make sequential reading EEPROM much easier.
Yes, I know that 0x55 and 0xaa need to be written into EECON2, and other EEPROM writing procedures
Just wonder I can read or write to the EEPROM without specifying the address all the time (only the first time), just read/write the next address of EEPROM (just like indirect addressing).
Just wonder I can read or write to the EEPROM without specifying the address all the time (only the first time), just read/write the next address of EEPROM (just like indirect addressing).
The data sheets on the 64K by 8 parts I looked at have a sequential read and block write.
With the sequential read you specify the address for the first read. After that the mem sends you a byte after you ack the one you just read until you stop acking them.
Yes! That's what I wanted to know. Thanks
How about the write cycle, same as what I said?
Another question of the write cycle is, the required sequence (such as writing 0x55 and 0xaa to EECON2) is needed to be done every time the address (EEADR) is updated? Or I can write to any address and do the required sequence for only once?
Am I right that the PIC takes 8 ms (max) to write to each address of the EEPROM? Or the whole process of writing to the EEPROM?
What is serial EEPROM? Is it external EEPROM IC that interfaced with the PIC?
*Thanks picasm for reminding about the lifespan of the PIC.
You have to do the 0x55, 0xaa sequence every time you write to EEPROM. As it takes up to 8mS (typically 4mS) to write to each location, the extra time involved in the sequence is irrelevant.
Serial EEPROM is an external chip that is accessed serially. Google 24LC64.
You have to do the 0x55, 0xaa sequence every time you write to EEPROM. As it takes up to 8mS (typically 4mS) to write to each location, the extra time involved in the sequence is irrelevant.
Serial EEPROM is an external chip that is accessed serially. Google 24LC64.
I've read the data EEPROM notes of Microchip, saying that
When the device is code protected, the CPU may continue to read and write the data EEPROM
memory. The device programmer can no longer access this memory.
So I was thinking, whether I can write a very short program, to write to the EEPROM, with code protected. Then program into the PIC and turn on the PIC to enable the writing.
Then I write another program which is reading from the EEPROM (no writing to the EEPROM in this program) and program into the same PIC. Can this be done?
So I was thinking, whether I can write a very short program, to write to the EEPROM, with code protected. Then program into the PIC and turn on the PIC to enable the writing.
Then I write another program which is reading from the EEPROM (no writing to the EEPROM in this program) and program into the same PIC. Can this be done?
:|
What I thought after reading the notes from Microchip is, when the chip is code protected, the EEPROM will not be erased by the programmer when it is reprogrammed. So it is supposed to be true that if I read from the EEPROM, I can get the data which is previously programmed in?
:|
What I thought after reading the notes from Microchip is, when the chip is code protected, the EEPROM will not be erased by the programmer when it is reprogrammed. So it is supposed to be true that if I read from the EEPROM, I can get the data which is previously programmed in?
If the chip is code protected, you have to wipe it entirely in order to remove the code protection - this is fairly obvious, otherwise it wouldn't be very good protection would it?.