Storing in PIC16F72 Memory ...?

Thread Starter

RRITESH KAKKAR

Joined Jun 29, 2010
2,829
Hi,

I want to store in PIC16F72 Flash memory which should delete after power off.
Actually my project is counter based using Hitech C.
 

ericgibbs

Joined Jan 29, 2010
18,867
hi,
You said: Flash memory which should delete after power off.
Normally Flash is not self erasing, as Mr C' points out its only SRAM data that is lost at power off.

Can you say which memory type you mean and why do you want to delete/erase flash memory data at power off.?
E
 

ErnieM

Joined Apr 24, 2011
8,377
I want to store in PIC16F72 Flash memory which should (not) delete after power off.
Actually my project is counter based using Hitech C.
To do this you open up the data sheet for the device and look for the section about accessing the flash directly.

If all you find is a section on how to read the memory then you need to find another device capable of the function you require.
 

JohnInTX

Joined Jun 26, 2012
4,787
If all you find is a section on how to read the memory then you need to find another device capable of the function you require.
Good call! Checking the datasheet shows NO internal EEPROM and the program flash can NOT be written by the program so there is no way to store data in non-volatile space. Battery backup for the RAM or a different PIC is in order.

Good luck.
 

kubeek

Joined Sep 20, 2005
5,795
Also think about the write endurance, you cant possibly expect the eeprom to last more than a few hundred thousand overwrites. If you need to do reliable storage of last state then make a capacitor backup such that when main power fails you trigger an interrupt and store the last value in eeprom. The cap needs to be big enough to provide charge for the write cycle with generous overhead.
Or just use an FRAM.
 

Thread Starter

RRITESH KAKKAR

Joined Jun 29, 2010
2,829
Code:
 #include <htc.h>
#include <stdio.h>

__CONFIG( BOREN_OFF & PWRTE_ON & WDTE_OFF & FOSC_HS & CP_OFF );

#define _XTAL_FREQ 20000000
char data[12]={0xDE,0X50,0b10111010,0b11111000,0b01110100,0b11101100,0b11101110,0b01011000,0b11111110,0b11111100} ;
main()
    {
    TRISB = 0 ;
    TRISC = 0 ;
ADCON0=0X00;
ADCON1=0B11111111;
TRISA = 0b11111100 ;
__delay_ms(500);
unsigned char a=0;
    while(1){

PORTA=0b00000010;//digit one multiplex
PORTB=data[a];// counter loaded value
__delay_ms(10);


PORTA=0b00000001;//digit one multiplex
PORTB=data[0]; // just used for test working fine or not
__delay_ms(10);



if(RA2==1){

__delay_ms(400);
a=a+1;


}
  if(RA3==1){

__delay_ms(400);
a=a-1;

} 

        }
    }
Hello,

I am using these code connected with seven segment display multiplex is working fine.
but i want to increment and decrement the counter as per switch.
 

joeyd999

Joined Jun 6, 2011
5,287
Also think about the write endurance, you cant possibly expect the eeprom to last more than a few hundred thousand overwrites. If you need to do reliable storage of last state then make a capacitor backup such that when main power fails you trigger an interrupt and store the last value in eeprom. The cap needs to be big enough to provide charge for the write cycle with generous overhead.
Or just use an FRAM.
I use "write-leveling" protocols to solve this problem...i.e I distribute the writes throughout the entire EEROM so as to increase the write endurance.

For instance, suppose I have 256 bytes of EE, and only 8 bytes of data to be stored. Each write occurs at the last write address + 8, then wraps around at the top. I use a checksum or time stamp to know which is the active record. In doing this, the write endurance will be multiplied by the EEROM size divided by the record size.

I also only process a write action only when the persistent data actually changes.
 

Thread Starter

RRITESH KAKKAR

Joined Jun 29, 2010
2,829
job done..



C:
#include <htc.h>
#include <stdio.h>

__CONFIG( BOREN_OFF & PWRTE_ON & WDTE_OFF & FOSC_HS & CP_OFF );

#define _XTAL_FREQ 20000000
char data[12]={0xDE,0X50,0xBA,0XF8,0X74,0XEC,0XEE,0X58,0XFE,0XFC} ;
main()
    {
    TRISB = 0 ;
    TRISC = 0 ;
ADCON0=0X00;
ADCON1=0B11111111;
TRISA = 0b11111100 ;
__delay_ms(500);
unsigned char a=0;
unsigned char div=0;
unsigned char rem=0;
    while(1){
rem = a%10;
PORTA=0b00000010;
PORTB=data[rem];
__delay_ms(10);

div=a/10;
PORTA=0b00000001;
PORTB=data[div];
__delay_ms(10);

if(RA2==1){
__delay_ms(80);
a=a+1;
if(a>99){
a=99;
}

}


  if(RA3==1){
__delay_ms(80);
a=a-1;
if(a>99){
a=0;
}
}
 
                }
                }
 
Top