Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 727717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:35:58+00:00 2026-05-14T06:35:58+00:00

Are there any PIC microcontroller programmers here? I’m learning some PIC microcontroller programming using

  • 0

Are there any PIC microcontroller programmers here?

I’m learning some PIC microcontroller programming using a pickit2 and the 16F690 chip that came with it. I’m working through trying out the various facilities at the moment. I can sucessfully read a byte from the EEPROM in code if I set the EEPROM vaklue in MPLAB but I don’t seem to be able to modify the value using the PIC itsself. Simply nothing happens and I don’t read back the modified value, I always get the original which implies to me that the write isn’t working?

This is my code for that section, am I missing something? I know I’m doing a lot of unnecessary bank switches, I added most of them to ensure that being on the wrong bank wasn’t the issue.

        ; ------------------------------------------------------
        ; Now SET the EEPROM location ZERO to 0x08
        ; ------------------------------------------------------

        BANKSEL EEADR
        CLRF    EEADR           ; Set EE Address to zero

        BANKSEL EEDAT
        MOVLW   0x08            ; Store the value 0x08 in the EEPROM
        MOVWF   EEDAT

        BANKSEL EECON1
        BSF     EECON1, WREN    ; Enable writes to the EEPROM

        BANKSEL EECON2
        MOVLW   0x55            ; Do the thing we have to do so
        MOVWF   EECON2          ; that writes can work
        MOVLW   0xAA
        MOVWF   EECON2

        BANKSEL EECON1      
        BSF     EECON1, WR      ; And finally perform the write

WAIT
        BTFSC   EECON1, WR      ; Wait for write to finish
        GOTO    WAIT

        BANKSEL PORTC           ; Just to make sure we are on the right bank
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T06:35:58+00:00Added an answer on May 14, 2026 at 6:35 am

    On page 122 of the 16F690 datasheet, it details the proper way to write to EEPROM:

    BANKSEL EEADR                   ;
    MOVF    DATA_EE_ADDR, W;
    MOVWF   EEADR          ;Data Memory Address to write
    MOVF    DATA_EE_DATA, W;
    MOVWF   EEDAT                   ;Data Memory Value to write
    BANKSEL EECON1                  ;
    BCF     EECON1, EEPGD ;Point to DATA memory
    BSF     EECON1, WREN   ;Enable writes
    BCF     INTCON, GIE             ;Disable INTs.
    BTFSC   INTCON, GIE             ;SEE AN576
    GOTO    $-2
    ; BEGIN REQUIRED SEQUENCE
    MOVLW   55h            ;       
    MOVWF   EECON2         ;Write 55h
    MOVLW   AAh                     ;
    MOVWF   EECON2                  ;Write AAh
    BSF     EECON1, WR              ;Set WR bit to begin write
    BSF     INTCON, GIE             ;Enable INTs.
    SLEEP                  ;Wait for interrupt to signal write complete
    ; END REQUIRED SEQUENCE
    BCF     EECON1, WREN   ;Disable writes
    BANKSEL 0x00           ;Bank 0
    

    I noticed that you are specifically missing this line:

     BCF     EECON1, EEPGD ;Point to DATA memory
    

    If EEPGD is always set, then you’ll try to write to program memory (aka overwrite the flash program memory) which should always fail unless you’ve gone out of your way to specifically enable that.

    Aside from that, as far as I can tell from reading your code, everything else looks fine. It’s okay that you’re polling EECON1.WR instead of setting an interrupt. It will cost you more power than putting the device to sleep, but of course you should just worry about one thing at a time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 417k
  • Answers 417k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I've got the answer now. ASP.NET fully supports JavaScript changing… May 15, 2026 at 9:32 am
  • Editorial Team
    Editorial Team added an answer So one solution to this problem is to create a… May 15, 2026 at 9:32 am
  • Editorial Team
    Editorial Team added an answer You need to put this in the head section of… May 15, 2026 at 9:32 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.