Hi,
I am facing a problem/difficulty while building a simple application using demo-board "DEMO9S12PFAME" for MC9S12P128. I have worked with Freescale 16-bit automotive MCUs in the past and I strongly suspect that the current problem may not be trivial. Would highly appreciate your assistance on this..
For you to be able to replicate the problem at your end on the same demo-board, I have described below a step-by-step procedure and have also attached the relevant project files:
The exact problem: Run-time failure. More specifically, CodeWarrior's True-Time Simulator reports an “illegal breakpoint” immediately after the attached code starts execution on the target device.
------------------------------------
* Hardware environment: DEMO9S12PFAME (Demo-board for MC9S12P128)
* Programming environment: CodeWarrior v4.7
* OS: Windows XP
Pls follow the following four steps to replicate the problem for the above-mentioned environment:
------------------------------------
Step 1: Create a new project using the following CodeWarrior options:
* Derivative: MC9S12P128
* Language: C
* Project set up for PC-lint (TM): No
* Level of startup code: ANSI startup code
* Floating point format: IEEE32 for both double and float
* Memory model: Small
* Connections: SofTec HCS12
Step 2: Copy the contents of the attached main.c into the main.c file for the project. Choose the “debug” button from CodeWarrior IDE for downloading code on the target.
Step 3: While downloading the code, choose the following option in true-time simulator & Real-time debugger:
* HW model - Code: DEMO9S12PFAME
Step 4: Click the "run" button. The device raises an “illegal breakpoint” error.
------------------------------------
Would appreciate your support.
Thanks.
Raj Panse
-----------------------------------------------------------------
P.S.: A description for the attachments is as follows:
1. Installed Plugins.TXT: Contains the CodeWarrior version details
2. Report.zip: Contains (zipped) project files. This project fails in the run-time by producing the reported problem.
3. main.c A copy of the main.c file from the project "Report".
-----------------------------------------------------------------
Have similliar kind of problems, but i have CW 5.9.
Code crashes during PE low level int and when i use debugger to "reset" program and press start/continue again code will work as it should be. what could cause that Illegal break point?
One noticetable feature is, that when i send a message to can bus, when i run this code without debugger, it wake ups the device.
At this version it crashes at PWM-init, when it executes HWEnDi there, but when I dissable PWM from the project the bug moves into next bean (in this case AD-module).
Any ideas, or is this a PE-bug in S12P?
current PE low level init code:
void PE_low_level_init(void)
{
/* Common initialization of the CPU registers */
/* WOMM: WOMM1=0 */
clrReg8Bits(WOMM, 2);
/* RDRM: RDRM5=0,RDRM4=0,RDRM3=0,RDRM2=0,RDRM1=0,RDRM0=0 */
clrReg8Bits(RDRM, 63);
/* TSCR1: TEN=0,TSWAI=0,TSFRZ=0,TFFCA=0,PRNT=1,??=0,??=0,??=0 */
setReg8(TSCR1, 8);
/* OCPD: OCPD7=1,OCPD6=1,OCPD5=1,OCPD4=1,OCPD3=1,OCPD2=1,OCPD1=1,OCPD0=1 */
setReg8(OCPD, 255);
/* PACTL: CLK1=0,CLK0=0 */
clrReg8Bits(PACTL, 12);
/* OC7M: OC7M0=0 */
clrReg8Bits(OC7M, 1);
/* TIOS: IOS7=1,IOS0=1 */
setReg8Bits(TIOS, 129);
/* TCTL2: OM0=0,OL0=0 */
clrReg8Bits(TCTL2, 3);
/* TTOV: TOV7=0,TOV0=0 */
clrReg8Bits(TTOV, 129);
/* TCTL1: OM7=0,OL7=0 */
clrReg8Bits(TCTL1, 192);
/* TSCR2: TOI=0,TCRE=1 */
clrSetReg8Bits(TSCR2, 128, 8);
/* TFLG1: C7F=1,C6F=1,C5F=1,C4F=1,C3F=1,C2F=1,C1F=1,C0F=1 */
setReg8(TFLG1, 255);
/* TIE: C0I=1 */
setReg8Bits(TIE, 1);
/* PTPSR: PTPS7=0,PTPS6=0,PTPS5=0,PTPS4=0,PTPS3=0,PTPS2=0,PTPS1=0,PTPS0=0 */
setReg8(PTPSR, 0);
/* PWME: ??=0,??=0,PWME5=0,PWME4=0,PWME3=0,PWME2=0,PWME1=0,PWME0=0 */
setReg8(PWME, 0);
/* PTTRR: PTTRR0=0 */
clrReg8Bits(PTTRR, 1);
/* PWMCTL: CON01=0,PSWAI=0,PFRZ=0 */
clrReg8Bits(PWMCTL, 28);
/* PWMCAE: CAE0=0 */
clrReg8Bits(PWMCAE, 1);
/* PWMPOL: PPOL0=0 */
clrReg8Bits(PWMPOL, 1);
/* PTP: PTP0=0 */
clrReg8Bits(PTP, 1);
/* DDRP: DDRP0=1 */
setReg8Bits(DDRP, 1);
/* ATDDIENL: IEN1=0,IEN0=0 */
clrReg8Bits(ATDDIENL, 3);
/* PORTA: PA3=0,PA0=0 */
clrReg8Bits(PORTA, 9);
/* PUCR: PUPAE=0 */
clrReg8Bits(PUCR, 1);
/* DDRA: DDRA3=1,DDRA0=1 */
setReg8Bits(DDRA, 9);
/* CPMUINT: LOCKIE=0,OSCIE=0 */
clrReg8Bits(CPMUINT, 18);
/* CPMULVCTL: LVIE=0 */
clrReg8Bits(CPMULVCTL, 2);
/* RDRIV: RDPE=0,RDPB=0,RDPA=0 */
clrReg8Bits(RDRIV, 19);
/* RDRJ: RDRJ7=0,RDRJ6=0,RDRJ2=0,RDRJ1=0,RDRJ0=0 */
clrReg8Bits(RDRJ, 199);
/* RDRP: RDRP7=0,RDRP5=0,RDRP4=0,RDRP3=0,RDRP2=0,RDRP1=0,RDRP0=0 */
clrReg8Bits(RDRP, 191);
/* RDRS: RDRS3=0,RDRS2=0,RDRS1=0,RDRS0=0 */
clrReg8Bits(RDRS, 15);
/* RDRT: RDRT7=0,RDRT6=0,RDRT5=0,RDRT4=0,RDRT3=0,RDRT2=0,RDRT1=0,RDRT0=0 */
setReg8(RDRT, 0);
/* RDR0AD: RDR0AD1=0,RDR0AD0=0 */
clrReg8Bits(RDR0AD, 3);
/* RDR1AD: RDR1AD7=0,RDR1AD6=0,RDR1AD5=0,RDR1AD4=0,RDR1AD3=0,RDR1AD2=0,RDR1AD1=0,RDR1AD0=0 */
setReg8(RDR1AD, 0);
/* IRQCR: IRQEN=0 */
clrReg8Bits(IRQCR, 64);
/* ### MC9S12P128_80 "Cpu" init code ... */
/* ### Init_MSCAN "CAN1" init code ... */
/* ### Call "CAN1_Init();" init method in a user code, i.e. in the main code */
/* ### Note: To enable automatic calling of the "CAN1" init code here must be
set the property Call Init in CPU init.code to 'yes' */
/* ### TimerInt "TI1" init code ... */
/* TC0: BIT15=0,BIT14=0,BIT13=0,BIT12=0,BIT11=1,BIT10=0,BIT9=0,BIT8=1,BIT7=1,BIT6=1,BIT5=0,BIT4=0,BIT3=0,BIT2=1,BIT1=0,BIT0=0 */
setReg16(TC0, 2500); /* Store given value to the compare register */
/* TC7: BIT15=0,BIT14=0,BIT13=0,BIT12=0,BIT11=1,BIT10=0,BIT9=0,BIT8=1,BIT7=1,BIT6=1,BIT5=0,BIT4=0,BIT3=0,BIT2=1,BIT1=0,BIT0=0 */
setReg16(TC7, 2500); /* Store given value to the modulo register */
/* ### WatchDog "WDog1" init code ... */
/* CPMUPROT: ??=0,??=0,??=1,??=0,??=0,??=1,??=1,PROT=0 */
setReg8(CPMUPROT, 38); /* Disable protection of clock-source register */
/* CPMUCLKS: PCE=0,COPOSCSEL=0 */
clrReg8Bits(CPMUCLKS, 5);
/* CPMUPROT: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,PROT=0 */
setReg8(CPMUPROT, 0); /* Re-Enable protection of clock-source register */
/* CPMUCOP: WCOP=0,CR2=0,CR1=0,CR0=1 */
clrSetReg8Bits(CPMUCOP, 134, 1);
/* ### Programable pulse generation "PWM6" init code ... */
PWM6_Init();
/* ### "AD1" init code ... */
AD1_Init();
/* ### BitIO "Bit1" init code ... */
Shadow_A &= (byte)~1; /* Initialize pin shadow variable bit */
/* ### IntFLASH "IFsh1" init code ... */
IFsh1_Init();
/* ### BitIO "Bit2" init code ... */
Shadow_A &= (byte)~8; /* Initialize pin shadow variable bit */
/* Common peripheral initialization - ENABLE */
/* TSCR1: TEN=1 */
setReg8Bits(TSCR1, 128);
__DI(); /* Disable interrupts */