Board logo

标题: [求助]PE生成的读写EEPROM的程序为什么总是跑飞? [打印本页]

作者: saserking    时间: 2007-5-28 21:45     标题: [求助]PE生成的读写EEPROM的程序为什么总是跑飞?

在main函数中循环调用EEP_SetActByte(data);写入字符串

用BDM调试发现总是在写入第2个字节时,执行modify sector操作的时候跑飞

另外用pe有点不清楚的地方是cpu的那一栏属性里工作模式应该选special single
还是 normal single ?接下来还有调整模式的选项都不知道应该怎样选。。。

下面是主函数部分的代码


/** ###################################################################
** Filename : eepromtest.C
** Project : eepromtest
** Processor : MC9S12DG128BCPV
** Version : Driver 01.11
** Compiler : Metrowerks HC12 C Compiler
** Date/Time : 2007-5-28, 19:59
** Abstract :
** Main module.
** Here is to be placed user's code.
** Settings :
** Contents :
** No public methods
**
** (c) Copyright UNIS, spol. s r.o. 1997-2005
** UNIS, spol. s r.o.
** Jundrovska 33
** 624 00 Brno
** Czech Republic
** http : www.processorexpert.com
** mail : info@processorexpert.com
** ###################################################################*/
/* MODULE eepromtest */

/* Including used modules for compiling procedure */
#include "Cpu.h"
#include "EEP.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"


const char s[20]="SaserKing";

volatile char a[20]={0};
volatile char b[20]={0};

void main(void)
{
unsigned int i;
unsigned int j;

/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
PE_low_level_init();
/*** End of Processor Expert internal initialization. ***/

__DI();

i=0;
while (s!=0) {
EEP_SetActByte(s);
i++;
}
EEP_SetActByte(0);

i=EEPROMStart;
while((*(char*)i) != 0)
{
a[i-EEPROMStart]=*(char*)i;
i++;
}

j=0;
while (s[j]!=0) {
EEP_SetByte(i,s[j]);
j++;
i++;
}
EEP_SetActByte(0);

i=EEPROMStart;
while((*(char*)i) != 0) {
b[i-EEPROMStart]=*(char*)i;
i++;
}



/* Write your code here */

/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
for(;;){}
/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

/* END eepromtest */
/*
** ###################################################################
**
** This file was created by UNIS Processor Expert 2.96 [03.76]
** for the Freescale HCS12 series of microcontrollers.
**
** ###################################################################
*/

作者: saserking    时间: 2007-5-29 13:32

关闭pll busclk=8M时正常
打开pll busclk-24M就跑飞

EEPROM会受pll影响么?
作者: strongchen    时间: 2007-5-29 13:39

EEPROM的时钟必须设置在150K~200KHz之间。
作者: saserking    时间: 2007-5-29 16:04

刚解决 3x

是开发板供电不稳的问题,所有程序都飞,和eeprom无关
pe果然好用




欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) Powered by Discuz! 7.0.0