Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Simulator and EECON1,WR

Status
Not open for further replies.

ibwev

Member
I am troubleshooting a program using MPLAB Simulator. In the code, I am learning to work with EEPROM by writting data to it and then trying to read from it. When writting data to EEPROM, the write control bit of EECON1 correctly sets. However, it does not clear after the information is written. The 16F690 datasheet says it is cleared by hardware. Can a set Write Control Bit of EECON1 clear while using the MPLAB Simulator. If so, how?
 
Great help. Polling the EEIF bit works in the MPLAB Simulator. I can now troubleshoot writes and reads in EEPROM.
 
But in modern PIC's like 16F886 it still does not clear.You have to poll the EEIF bit for a write complete.

Not according to the data sheet.

eeprom-png.55467


Mike.
 

Attachments

  • eeprom.png
    eeprom.png
    65.8 KB · Views: 260
Last edited:
I think this shed some light in here

Interrupt flag bit EEIF
The user can either
enable this interrupt or poll this bit. EEIF must be
cleared by software.
 
Last edited:
Just tried this and the WR bit does get cleared in the simulator.

Code (BoostC format) for any one to try,
Code:
#include <system.h>

#pragma DATA _CONFIG, _DEBUG_OFF & _MCLRE_ON
                    & _CP_OFF & _PWRTE_OFF
                    & _WDT_OFF & _INTOSCIO
                    & _LVP_OFF

#pragma CLOCK_FREQ 8000000


void main(void){
    osccon=0x71;            //8 meg
    ansel=0;
    anselh=0;

    eedata=0x23;
    eeadr=0;
    eecon1=0b0000100;

    eecon2=0x55;
    eecon2=0xaa;
    eecon1.WR=1;

    while(eecon1.WR);

    while(1){

    }//end while
}//end main

Edit, it will not work if you single step through the code as the required sequence doesn't get followed.

Mike.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top