pic12f629 EEPROM problem in MPLABSIM


Closed Thread
Results 1 to 2 of 2

Hybrid View

  1. #1
    nicholastyc's Avatar
    nicholastyc Guest

    Default pic12f629 EEPROM problem in MPLABSIM

    Hi,
    By the way, my new problem is i saved my data (0x01) into eeprom address 0x01, when i recall the data it does not recall the same data but something different from it and sometimes i can save the data and recall correctly but sometimes not.
    What is the problem? is the setting or code problems? i already DOUBLExDouble check it in the DATASHEET for few hours and look for solutions on internet, i still cant recall correctly, PLEASe HELP.I write the data correctly...everytime, when i check in the EEDATA register b4 i reset the MPLAB SIM and rerun again.
    Code Below, PIC12F629 ,
    WRITE code from me,
    ORIGINAL_PWM EQU 0x21
    TEMP EQU 0x22
    WRITE: BSF STATUS,5; switch to bank 1
    MOVLW 0x01; go to addr 0x01
    MOVWF EEADR;
    MOVF ORIGINAL_PWM,w ; (ORIGINAL_PWM = 0x01)
    MOVWF EEDATA; write 0x01 to EEDATA
    BSF EECON1,WREN; < follow the datasheet write process
    BCF INTCON,GIE ;<
    MOVLW H'0055' ;<
    MOVWF EECON2 ;<
    MOVLW H'00AA' ;<
    MOVWF EECON2 ;<
    BSF EECON1,WR ;<
    BSF INTCON,GIE ;<
    BCF STATUS,5; switch to bank 0
    RETURN

    READ: BSF STATUS,5; switch to bank 1
    MOVLW 0x01; goto addr 0x01 in eeprom
    MOVWF EEADR;
    BSF EECON1,RD ; read previously saved data 0x01
    MOVF EEDATA,w ; move 0x01 to w
    MOVWF TEMP; (TEMP register ) move 0x01 to TEMP
    BCF STATUS,5; switch bank 0
    RETURN


    Thanks for help

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    MPSIM can be a real pain in few occasion, what i suggest is to loop on the READ subroutine and wait the Watch Windows to refresh.

    Code:
            include     P12F629.inc
            errorlevel -302
            __CONFIG    _INTRC_OSC_NOCLKOUT & _MCLRE_ON & _WDT_OFF & _PWRTE_ON & _BODEN_ON 
            
    MyData = 0xFA ; whatever your value
    MyAddr = 0x10 ; EEPROM Address    
    TEMP            EQU 0x21
    
            org     0
            call    WRITE
            call    READ
            goto    $-1
    
    
    
    WRITE: 
            BANKSEL EECON1
            MOVLW   MyAddr
            MOVWF   EEADR
            MOVLW   MyData
            MOVWF   EEDATA
            BSF     EECON1,WREN
            MOVLW   0X55
            MOVWF   EECON2
            MOVLW   0XAA
            MOVWF   EECON2
            BSF     EECON1,WR
            BCF     EECON1,WREN
            RETURN
    
    READ: 
            BANKSEL EEADR
            MOVLW   MyAddr
            MOVWF   EEADR;
            BSF     EECON1,RD 
            MOVF    EEDATA,W 
            BANKSEL TEMP
            MOVWF   TEMP  
            RETURN
            
            end
    NOTE: This may not work in 'Animate' mode.
    Last edited by mister_e; - 16th May 2008 at 18:21.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Can't read sequential addresses in external EEPROM
    By tjkelly in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th February 2010, 14:46
  2. Problem with I2C EEPROM addressing
    By Atom058 in forum General
    Replies: 14
    Last Post: - 3rd November 2009, 03:17
  3. Problem with 12F629, servo and EEPROM
    By Atom058 in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 1st March 2008, 09:53
  4. How to write/read strings EEPROM/LCD
    By g-hoot in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 11th February 2007, 06:26
  5. word variable to 25lc640
    By TONIGALEA in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 6th July 2004, 19:59

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts