Sign in

username:

password:



Not a member?

Search 68hc12



Search tips

Subscribe to 68hc12



68hc12 by Keywords

68HC1 | 812A4 | 9S12DP256 | Bootloader | CodeWarrior | D60A | Debugger | DP256 | ECT | EEPROM | EVB | Flash | HC1 | HCS12 | I2C | IAR | ICC1 | Interrupts | LCD | M68KIT912DP256 | MC9S12DP256 | MC9S12DP256B | Metrowerks | Motor | MSCAN | Multilink | PLL | Quadrature | SDI | SPI | Transceiver | XFC


Ads

Discussion Groups

See Also

DSPFPGAElectronics

Discussion Groups | 68HC12 | =?iso-8859-1?q?I_can=B4t_write_data_to_the_flash_memory?=

Join our technical discussions about Freescale Microcontrollers: M68HC12. (Freescale Semiconductor is a Subsidiary of Motorola).

=?iso-8859-1?q?I_can=B4t_write_data_to_the_flash_memory?= - bolourchian45 - Aug 14 13:26:53 2009



Hello everybody,

=20

I am developing a project with CodeWarrior IDE 5.9.0 and Processor Expert.

I am working with 16 bit MCU =96 9S12E128QFP80 with PE BDM and simulation p=
rogram.(Visualizing)

The problem is, I can not write data in the flash memory. Actually I am try=
ing to use the address at 0x4000 or 0x8000 but every time I try to get val=
ue, the status is showing error (ret =3D FF) and also after programming whe=
n the program is running every things will mix up and I should disable the =
bean protection option to run the program again..

I used the flash int. bean with no protection for flash memory. I believe s=
omething is missing here.

In following you have the program.

Please help me.

Thanks

P.S. the hardware is tested before so I can not believe this is a hardware =
problem

=20

---------------------------------------------------------------------------=
----------------------------------

=20

=20

/* MODULE Project11_00 */

/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "Events.h"
#include "AI0.h"
#include "K1.h"
#include "K2.h"
#include "K3.h"
#include "K4.h"
#include "Glob_load.h"
#include "LED_G1.h"
#include "LED_G2.h"
#include "LED_R1.h"
#include "LED_R2.h"
#include "Buzzer.h"
#include "GP_Enable.h"
#include "TI1.h"
#include "TI2.h"
#include "ShutDown.h"
#include "FLASH1.h"
#include "Pump_1_Bit.h"
#include "Pump_2_bit.h"
#include "BF_1.h"
#include "BF_2.h"
/* Include shared modules, which are used for whole project */
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"
#include
#include
unsigned char F_WRT(void);
unsigned char F_ERASE(void);
unsigned long ratio=3D0,cnt_00=3D0,cnt_02=3D0,cnt_03=3D0;
=20
volatile long int x0,x1,x2,x3,x4,Pressure_0,Temp_1,Temp_2,Temp_3;
float y2,Volt_1,Volt_2, Volt_3 ;

=20
volatile short i=3D0;
=20
bool key1=3DFALSE,pb1=3DFALSE,pb2=3DFALSE,pb3=3DFALSE,pb4=3DFALSE,i1=3D FA=
LSE;
bool FL00=3D0,FL01=3D0,FL02,FL03,FL04;
unsigned char cnt_01=3D0,dt=3D100;
unsigned int data[4] @0x4000;
unsigned char R1,ret;

unsigned char F_WRT(void)
=20=20=20=20=20=20
{
FCMD =3D 0x20;
FSTAT =3D 0x80;
ret =3D 0xFF;
if(!FSTAT&&FSTAT_PVIOL_MASK)
if(!FSTAT&&FSTAT_ACCERR_MASK)
ret =3D 0x00;
return ret;
=20=20=20=20=20=20=20=20=20
=20=20=20=20=20=20=20=20=20
}
unsigned char F_ERASE(void)
=20=20=20=20=20=20
{
FCMD =3D 0x40;
FSTAT =3D 0x80;
ret =3D 0xFF;
if(!FSTAT&&FSTAT_PVIOL_MASK)
if(!FSTAT&&FSTAT_ACCERR_MASK)
ret =3D 0x00;
return ret;
=20=20=20=20=20=20=20=20=20
=20=20=20=20=20=20=20=20=20
}
=20=20=20=20=20=20=20=20=20=20

void main(void)
{
=20
=20
=20
/* local variable definition */
=20
word value[1];
=20
ShutDown_ClrVal();
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! =
***/
PE_low_level_init();
/*** End of Processor Expert internal initialization. =
***/

/* Write your code here */
=20
=20
=20
=20
for (R1=3D0; R1 < 4; R1++ ) {
=20=20=20=20=20
data[R1]=3D0;
ret =3D F_ERASE();
}
=20
R1 =3D 0;
data[R1++] =3D 0x00;
data[R1++] =3D 0x01;
ret =3D F_WRT();
data[R1++] =3D 0x02;
data[R1++] =3D 0x03;
ret =3D F_WRT();
=20=20
for(;:smileywink:{ ...............................................=
..........................................}
=20=20

=20

=20

------------------------------------



(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )