A discussion group for the PICMicro microcontroller. Also called the Microchip PIC, this list is dedicated to the use and abuse of this fine, simple, microcontroller. Close to topic posts are welcome, ie. general electronics.
|
I am having a problem wiping the first 16 bytes of the EEPROM through my code. I ran it through the simulator, it WORKS fine. But when I burn it to the PIC, it only erases the FIRST location of eeprom and that is all. So basically the proper registers are loaded with data, and there is a loop to write each location of the eeprom with FF, have I missed something here? Any ideas would be appreciated, thank you. PREPARE: CLRF EEADR ;Clear EE address counter MOVLW 010h ;Move 10h (16) to W MOVWF EEADRLEN ;Move 10h (16) to counter MOVLW 0FFh ;Move FFh to W MOVWF EEDATA ;Move FFh to EEDATA BEGINWRITE: CALL ERASE INCF EEADR, F DECFSZ EEADRLEN GOTO BEGINWRITE RETURN ERASE: BSF STATUS, RP0 ;Bank 1 BCF INTCON, 7 ;Disable Interupts BSF EECON1, 2 ;Enable Write MOVLW 55h MOVWF EECON2 ;55h MUST be written to EECON2 MOVLW 0xAA ;to start write sequence MOVWF EECON2 ;Write AAh BSF EECON1, 1 ;Set WR bit begin write BSF INTCON, 7 ;Enable INT's BCF STATUS, RP0 ;Bank 0 RETURN |
|
|
|
In your erase code,
poll the WR bit for a
write complete. The eeprom write takes
sometimes a few Msec
to complete. I would add this
after you set the WR bit
to start the write, BTFSC EECON,WR ;check the wr bit for a complete write GOTO
$-1
;
if not complete poll again The Pic will automatically
set the bit to 0 after a successfully write. Jamie -----Original Message----- I am having a problem
wiping the first 16 bytes of the
EEPROM through Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. |