查看: 2570|回复: 0

ZVL32可以正常调试,脱离PE后上电无法运行

[复制链接]

该用户从未签到

18

主题

52

帖子

0

注册会员

Rank: 2

积分
127
最后登录
2021-3-12
发表于 2021-3-8 15:59:51 | 显示全部楼层 |阅读模式
9S12ZVL32
codewarrior11.0
各位:
我这边写了一个程序,PE在线调试正常运行,PE断开,重新上电就无法运行。
请帮我看下,问题出在哪里?
硬件肯定是没有问题的,问题应该出在程序上面。
附件是完整工程,我这边再贴下main.c内容

#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */

#define clrSetReg8Bits(RegName, ClrMask, SetMask) (RegName = (RegName & ((byte)(~(byte)(ClrMask)))) | (byte)(SetMask))
#define setReg16(RegName, val) (RegName = (word)(val))
#define setReg8(RegName, val) (RegName = (byte)(val))
#define setReg8Bits(RegName, SetMask) (RegName |= (byte)(SetMask))
#define clrReg8Bits(RegName, ClrMask) (RegName &= (byte)(~(byte)(ClrMask)))
#pragma CODE_SEG __NEAR_SEG NON_BANKED /* Suppress generation of return from a function */
extern void _Startup(void); /* Forward declaration of external startup function declared in file Start12.c */
/*** !!! Here you can place your own code using property "User data declarations" on the build options tab of the CPU component. !!! ***/
#pragma NO_RETURN /* Forward declaration of external startup function declared in file Start12.c */
void _EntryPoint(void);
void _EntryPoint(void)
{
/*** !!! Here you can place your own code using property "User code before PE initialization" on the build options tab of the CPU compoennt. !!! ***/

/* ### MC9S12ZVL32_48 "Cpu" init code ... */
/* PE initialization code after reset */
/* IVBR: IVB_ADDR=0x7FFF,??=0 */
setReg16(IVBR, 0xFFFEU);
/* ECLKCTL: NECLK=1,??=0,??=0,??=0,??=0,??=0,??=0,??=0 */
setReg8(ECLKCTL, 0x80U);
/* System clock initialization */
/* CPMUPROT: 去除保护必须赋值0x26 PROT = 0 */
setReg8(CPMUPROT, 0x26U);
/* CPMUCLKS: PSTP=0 */
clrReg8Bits(CPMUCLKS, 0x40U);
/* CPMUCLKS: PLLSEL=1 */
setReg8Bits(CPMUCLKS, 0x80U); /* Enable the PLL to allow write to divider registers */
/* CPMUPOSTDIV: ??=0,??=0,??=0,POSTDIV4=0,POSTDIV3=0,POSTDIV2=0,POSTDIV1=0,POSTDIV0=1 */
setReg8(CPMUPOSTDIV, 0x01U); /* Set the post divider register */
/* Whenever changing PLL reference clock (REFCLK) frequency to a higher value
it is recommended to write CPMUSYNR = 0x00 in order to stay within specified
maximum frequency of the MCU */
/* CPMUSYNR: VCOFRQ1=0,VCOFRQ0=0,SYNDIV5=0,SYNDIV4=0,SYNDIV3=0,SYNDIV2=0,SYNDIV1=0,SYNDIV0=0 */
setReg8(CPMUSYNR, 0x00U); /* Set the multiplier register */
/* CPMUPLL: ??=0,??=0,FM1=0,FM0=0,??=0,??=0,??=0,??=0 */
setReg8(CPMUPLL, 0x00U); /* Set the PLL frequency modulation */
/* CPMUSYNR: VCOFRQ1=0,VCOFRQ0=0,SYNDIV5=0,SYNDIV4=0,SYNDIV3=1,SYNDIV2=1,SYNDIV1=1,SYNDIV0=1 */
setReg8(CPMUSYNR, 0x0FU); /* Set the multiplier register */
while(CPMUIFLG_LOCK == 0U) { /* Wait until the PLL is within the desired tolerance of the target frequency */
}
/* CPMUPROT: PROT=1 除0x26外的其它值都可以使能保护 */
setReg8(CPMUPROT, 0x01U);
/* CPMUCOP: RSBCK=0,WRTMASK=1 */
clrSetReg8Bits(CPMUCOP, 0x40U, 0x20U);
/* CPMUHTCTL: ??=0,??=0,VSEL=0,??=0,HTE=0,HTDS=0,HTIE=0,HTIF=0 */
setReg8(CPMUHTCTL, 0x00U);
/* CPMUVREGCTL: ??=0,??=0,??=0,??=0,??=0,??=0,EXTXON=0,INTXON=1 */
setReg8(CPMUVREGCTL, 0x01U);
/*** End of PE initialization code after reset ***/
/*** !!! Here you can place your own code using property "User code after PE initialization" on the build options tab of the CPU component. !!! ***/
/*lint -save -e950 Disable MISRA rule (1.1) checking. */
__asm(jmp _Startup); /* Jump to C startup code */
/*lint -restore Enable MISRA rule (1.1) checking. */
}
#pragma CODE_SEG NON_BANKED
void ISR_RESET(void);
interrupt VectorNumber_Vreset void ISR_RESET(void)
{
__asm(BGND);
_EntryPoint();
}
#pragma CODE_SEG DEFAULT
void main(void) {
unsigned long i;
DDRE = 0xff;
DDRP = 0xff;
PTE = 0xff;
PTP = 0xff;
/* include your code here */

for(;;) {
//__RESET_WATCHDOG(); /* feeds the dog */
for(i=0;i<10000;i++){};
PTE=0;
for(i=0;i<10000;i++){};
PTE=0xff;
} /* loop forever */
/* please make sure that you never leave main */
}

CSM_R_test.rar

145.24 KB, 下载次数: 0, 下载积分: 威望 1

回复

使用道具 举报

您需要登录后才可以回帖 注册/登录

本版积分规则

关闭

站长推荐上一条 /4 下一条

Archiver|手机版|小黑屋|恩智浦技术社区

GMT+8, 2024-4-20 00:03 , Processed in 0.121153 second(s), 19 queries , MemCache On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表