Sign in

username:

password:



Not a member?

Search piclist



Search tips

Subscribe to piclist



piclist by Keywords

12F675 | 16F628 | 16F84 | 16f877 | 16F877A | 16F88 | 18F458 | ADC | AVR | Bootloader | CAN | CCS | CRC | EAGLE | EEPROM | ICD | ICSP | IDE | JDM | LED | Macros | Microchip | MPLAB | PCB-CAD | PIC10F | Pic12f675 | PIC16F84 | PIC16F84A | PIC16F877 | PIC18 | PIC18F452 | PicBasic | PICC | PICSTART | PWM | RS-485 | RS232 | SMT | SPI | UART | USART | USB | Wireless | Wisp628 | Xilinx

Ads

Discussion Groups

Discussion Groups | Piclist | Erasing EEPROM through Code

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.

Erasing EEPROM through Code - tallevi21 - Aug 2 23:01:00 2003

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





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )


RE: Erasing EEPROM through Code - Jamie Starling - Aug 3 8:53:00 2003

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-----
From: tallevi21 [mailto:k...@rogers.com]
Sent: Sunday, August 03, 2003 12:01 AM
To: p...@yahoogroups.com
Subject: [piclist] Erasing EEPROM through Code

 

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


to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.






(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )