Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Accessing Flash memory of C8051F120 chip

Status
Not open for further replies.

ajfreak

Newbie level 3
Joined
Nov 30, 2007
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,307
flash_read silicon labs

Hi der,
Can ne1 plz suggest me a proper code to access flash memory of C8051F120 in Keil C.m not sure how to conver d MOVX n MOVC instructions in C. Also m kinda uncertain abt d proper order of d sfr assignments...
:!:
 

walygat

Newbie level 5
Joined
Mar 28, 2006
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,323
i try this with F310 silicon Labs and it work well.


in variables declaration zone for example

xdata unsigned int toto[20];

in use toto[6]=0X55;

i hope this will help you.
 

ajfreak

Newbie level 3
Joined
Nov 30, 2007
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,307
HEY THANKX FOR TAT SOLN.
BUT COULD U PLZ TELL ME HOW EXACTLY U USED IT IN UR CODE ...
PLZ GO THRU D FOLLOWING ROUTINES N TELL ME WER M GOIN WRONG....


void Flash_erase()
{


//Disable interrupts

PSBANK = 0X11; //BANK 1
FLSCL = 0X01; ///ENABLE FLASH WRITE/ERASE
PSCTL = 0X02; //ERASE LOC PRIOR TO WRITING
PSCTL = 0X01; //ERASE LOC PRIOR TO WRITING
DPH = 0X80;
DPL = 0X00;
PSCTL = 0X00; //disable flash erase by clearing PSEE
// PSCTL = 0X00; //clear pswe to redirect movx to xram
FLSCL = 0X00; //disable flash write
//re-enable interrupts

}


void Flash_write(unsigned char *s)
{

xdata unsigned char inp_reg2[20];


while(*s != '\0')
{
ACC = *s;

IE = 0X00; //Disable interrupts
CCH0CN = 0x00;
PSBANK = 0X11; //BANK 1
FLSCL = 0X01; ///ENABLE FLASH WRITE/ERASE
PSCTL = 0X01; //ERASE LOC PRIOR TO WRITING
inp_reg2[6]= 0x0080;
// DPH = 0X80;
// DPL = 0X00;
FLSTAT = 0X01;
//inp_reg1=P1;

*inp_reg2=ACC;

// DPL++;

// DPL = ACC;
// XBYTE[0x1234] = 0x55;
PSCTL = 0X00; //disable flash erase by clearing PSEE
// PSCTL = 0X00; //clear pswe to redirect movx to xram
FLSCL = 0X00; //disable flash write
//re-enable interrupts

}

}



unsigned char *Flash_read()
{
unsigned char xdata inp_reg2;


//Disable interrupts
PSBANK = 0X11; //BANK 1
FLSCL = 0X00; ///ENABLE FLASH WRITE/ERASE
PSCTL = 0X01; //ERASE LOC PRIOR TO WRITING
DPH = 0X80;
DPL = 0X00;
FLSTAT = 0X00;
ACC=inp_reg2;

// ACC = DPL;
// XBYTE[0x1234] = 0x55;
// PSCTL = 0X01; //disable flash erase by clearing PSEE
PSCTL = 0X00; //clear pswe to redirect movx to xram
FLSCL = 0X00; //disable flash write

return ACC;
}


HOPEFULLY DIS WILL HELP IN TROUBLESHOOTING MA PROB....
 

prasadsrkrec

Junior Member level 2
Joined
May 18, 2012
Messages
23
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,421
I am using this code for flash erase flash write and flash read..

i am storing succesfully in one value by using this instruction. but problem is
i want to store another value in another location of flash memory.. but i am confusing their addresses..

kindly help me..
Plss
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top