hello,
i am doing a project on Mc9s12a128b and using external flash memory m29f040b (two of them)so need to know how to write data into flash. ############# getting write,chip select and read signals.PLD is used to selct the external flash memeory. ########## register settings MODE = 0xEAL;/*writing values to mode register to choose the mode and set EMK bit*/ MISC = 0x0DL;/*to stretch the clock cycles*/ PPAGE = 0x00L;/*page value into PPAGE register*/ PEAR = 0x0CL; /*port E assignment register*/ PUCR = 0x90L;/*pull up control register to enable input pins*/ EBICTL = 0x01L;/*EXTERNAL BUS INTERFACE CONTROL REGISTERS*/ PORTK = 0x40L;/*select the external chip for external accesses and made it X40 from X80*/ //PORTK = 0x60L; CSCTL0=0x3F; CSCTL1=0x3D; CSSTR0=0x3E; CSSTR1=0x3F; WINDEF=WINDEF | 0xC0; PORTE = 0x10L;
PORTA = 0xFF; PORTB = 0xFF;
****************** flash write function:addr1 is sent the ext flash address void FlashWrite1(volatile unsigned short *addr1,volatile unsigned short *addr11,unsigned short ucVal ) {unsigned short volatile *addr2; addr2=(unsigned short volatile *)0x0FF0; //(*addr2)=0x7F12; //&addr2=0x7F12; ///addr2=&ucVal; //*addr2=0x03;
*addr2=ucVal;*addr1=*addr2;/* writing into required address*/
*addr11=*addr2;/*writing into int flash*/ }thank u in advance for the help ranjita, blore,india