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.

Erase In Flash Program

Status
Not open for further replies.
You have to erase a full block each time. The only way to erase a word is to read the block into ram, erase it and write back the block with the word erased.

Mike.
 
thanks pommie

do u have any c program to read write data into program memory block. am working in pic18f (mplab)
 
I'd love to know if there's a better way than how I did it in C18;

Code:
/*****************************************************************
 *  functions                                                    *
 *****************************************************************/

void TBLWRPOSTINC_Func (void)
{ _asm TBLWTPOSTINC _endasm }

void TBLRDPOSTDEC_Func (void)
{ _asm TBLRDPOSTDEC _endasm }

void TBLRDPOSTINC_Func (void)
{ _asm TBLRDPOSTINC _endasm }

void TBLWR_Func (void)
{ _asm TBLWT _endasm }
Code:
/*****************************************************************
 *  erase, write, and verify buffer (64 code or 8 IDLOC bytes)   *
 *****************************************************************/

void Write_Buffer (void)
{ if (Row_Count)                //  don't write an empty buffer
  { Set_TBLPTR ();              //  erase 64 byte 'row'
    Write (0b10010100);         //  EEPGD=1/CFGS=0/FREE=1/WREN=1

    for (x=0; x<Row_Count; x++) //  write 64 byte 'row'
    { TABLAT = Row_Buffer[x];
      TBLWRPOSTINC_Func ();     //
    }
    TBLRDPOSTDEC_Func ();       //  fix TBLPTR, do "long write"
    Write (0b10000100);         //  EEPGD=1/CFGS=0/FREE=0/WREN=1

    Set_TBLPTR ();              //  verify 64 byte 'row'
    for (x=0; x<Row_Count; x++)
    { TBLRDPOSTINC_Func ();
      if (TABLAT != Row_Buffer[x])
      { Error_Flag = 0x04;      //  indicate verify error
      }
      Row_Buffer[x] = 0xFF;     //  reset row buffer byte to FF
    }
    Row_Count = 0;              //  indicate row buffer empty
  }
}
 
Last edited:
flash read write

i am using pic18f series in mplab ide2.
firstly i worked in mplab sim. there i was able to write to program memory and then again read it back.

when i connected the actually hardware using pickit. the flash data is not getting stored in the address which i specify . also out of 60 bytes of data i was ablle to read 50 bytes but not the rest 10 bytes ... please help me in this issue...
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top