ZVL32无法正常运行

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ZVL32无法正常运行

859 Views
zhou
Contributor III

9S12ZVL32

codewarrior11.0

各位:

我这边写了一个程序,PE在线调试正常运行,PE断开,重新上电就无法运行。

请帮我看下,问题出在哪里?

硬件肯定是没有问题的,问题应该出在程序上面。

附件是完整工程,我这边再贴下main.c内容

(translation by web translator:

I wrote a program here, PE online debugging normal operation, PE disconnect, power up again will not be able to run.

Please look for me, what's the problem?

Hardware is definitely no problem, the problem should be on the program.

The attachment is complete and I'll post it on my side


)

#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 */

}

 

0 Kudos
3 Replies

843 Views
StanoA
NXP TechSupport
NXP TechSupport

Hello Zhou,

I looked on you code and I would suggest you several code corrections:

first:

void main(void) {
unsigned long i;
//DDRE = 0xff;
DDRP = 0xff;
//PTE = 0xff;
PTP = 0xff;
/* include your code here */

second:

for(;;) {
//__RESET_WATCHDOG(); /* feeds the dog */
for(i=0;i<10000;i++){};
PTP=0;
for(i=0;i<10000;i++){};
PTP=0xff;

} /* loop forever */

If you need such other help feel free to ask.

Best Regards,

Stano.

0 Kudos

831 Views
zhou
Contributor III

Hello Stano:

thank you for your answer.

i try to use you code,but it is not work.

zhou_1-1615357578907.png

in the debug mode ,press restart button can work,

press reset button can not work,the error like the picture

zhou_2-1615357844982.png

 

so,what is the problem.

Best Regards,

zhou

 

0 Kudos

826 Views
StanoA
NXP TechSupport
NXP TechSupport
Dear sean zhou, 
When you press the RESET button (black arrow in red circle) on the debug window the next small window appears:
StanoA_0-1615369718824.png

Please fill in the path as showed in my example, but it must fit to you SW. Then when you press RESET (in blue on picture) the reset will function.

Best regards,

Stano. 

 
 
0 Kudos