hello, support team
i followed AN5330 to migrate, i finished all steps in chapter 4 ,but still got problems.
can you help to debug if the function and LIN comm is ok?
is there any diffrence between L31 version and L128/L64/L32 not mentioned in AN5330?
remarks :i changed the cpmu.c and pim .c from original , if useless pls use the original code.
thanks
已解决! 转到解答。
Hi NoahXu,
This obviously looks like you defined the interrupt vector twice and they overlap.
The source project has a bit of complicated interrupt vectors definitions due to compatibility with CW and Cosmic compilers. But the main vector table _vectab[] is located in vector.c file.
As I can see in the code, you added ISRs definitions via interrupt keyword and interrupt number like:
interrupt VectorNumber_Vtim0ch3 void TIM0chan3_ISR(void)
As a result, the TIM0 channel 3 interrupt vector is defined twice.
So, you have to either modify newly added interrupts to syntax used by original project (use only "INTERRUPT" keyword, they will be part of _vectab,...) or you have to abadon the _vectab vector table and rewrite original ISRs to style that you used in your modifications (keyword "interrupt" plus vector number). Optionally you may define the vector number in prm linker file intead of C code.
The might be always only one definition for each of interrupt vector.
Advantage of vector table is that it covers also the unexpected interrupt situation while independent interupt vectors definition is more simple to understood.
As I already mentioned, the source vector table definition is prepared also for Cosmic compiler while the "interrupt" keyword meaning is CodeWarrior compiler specific.
Please be also aware that the memory overlaping warning is disabled by default. For more details: https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12Z-constant-variable-code-allocation-in-C...
I hope it helps you.
BR
RadekS
Hi, Radek thanks again for your post.
I imported the SW project to code warrior 11, it seems all the AMMC lib not included in the sw package, so i copied the AMMCLIB_v1.1.14 to the project and updated the include path in the properties.
however i got many errors after build .Interesting thing is i already include the lib, but the IDE hint is :"the file'gdflib.h' cannot be opened".
is it caused by the code warrior version? if yes can you post the link to download?i only found the V11 and also in the previous version i found V10 for eTPU .
Hi NoahXu,
you are right, the sw project does not contain the AMMCLib inside the project.
The error means that AMMCLib was not included properly.
The AMMCLib in the source project is linked from the default folder C:\\NXP\AMMCLIB\MC9S12ZVM_AMMCLIB_v1.1.xx
where xx may vary according to your AMMCLib installation.
The latest AMMCLib (currently 1.1.33; you may download also previous versions) may be downloaded from nxp.com/AMMCLib
The path to the library must be updated on three places in project settings (in Linker, Compiler, Assembler sections). See highlighted positions on picture:
just double-click on the path and rewrite the number 27 to version that you installed into default location.
The API should be fully compatible across AMMCLib versions. So, you should be able to use almost any version.
Hint: I would like to recommend also clean project before building everytime when you import any project (there might be files in FLASH folder that cause problem with paths). Optionaly you may delete the FLASH folder and Refresh (F5) the project.
It seems that I forgot to clean the FLASH folder prior sharing.
BR
RadekS
Morning,Radek thanks for your solution, i compiled the code with success result.
when i go into the next step which is LIN stack integration, i found another issue:
"INF: block 00FFFE10-00FFFFFF ...
INF: Calculated CRC-16 does not match block. (File = $8E62, Device = $FB36)
ERR: Error verifying flash of device
ERR: Error occured during Flash programming."
i checked the linker file according to the address "00FFFE10-00FFFFFF" and it seems the interrupt vectors are set wrong with my project, but i cannot find why. can you help to check again for the issue?
Hi NoahXu,
This obviously looks like you defined the interrupt vector twice and they overlap.
The source project has a bit of complicated interrupt vectors definitions due to compatibility with CW and Cosmic compilers. But the main vector table _vectab[] is located in vector.c file.
As I can see in the code, you added ISRs definitions via interrupt keyword and interrupt number like:
interrupt VectorNumber_Vtim0ch3 void TIM0chan3_ISR(void)
As a result, the TIM0 channel 3 interrupt vector is defined twice.
So, you have to either modify newly added interrupts to syntax used by original project (use only "INTERRUPT" keyword, they will be part of _vectab,...) or you have to abadon the _vectab vector table and rewrite original ISRs to style that you used in your modifications (keyword "interrupt" plus vector number). Optionally you may define the vector number in prm linker file intead of C code.
The might be always only one definition for each of interrupt vector.
Advantage of vector table is that it covers also the unexpected interrupt situation while independent interupt vectors definition is more simple to understood.
As I already mentioned, the source vector table definition is prepared also for Cosmic compiler while the "interrupt" keyword meaning is CodeWarrior compiler specific.
Please be also aware that the memory overlaping warning is disabled by default. For more details: https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12Z-constant-variable-code-allocation-in-C...
I hope it helps you.
BR
RadekS
Hi,Radek
thanks for your reminder, the complie is success.
i use this style syntax"interrupt VectorNumber_Vtim0ch3 void TIM0chan3_ISR(void)" for all interrupts and also comment out the line "//vector INTO OSVECTORS; /* OSEK */" in linker file . is it ok?
the second question is that the lin message cannot sent out. the project is based on AN5327_SW_CW10+LIN STACK_S12_4_6_6, the evaluation board is MTRCKTSPNZVML31. currently :complie success, but no lin message sent out (i use canoe to schedule the lin table). can you kindly check the code?
Hi NoahXu,
I ported sw project to S12ZVML31 some time ago, but I didn't follow the AN5330. I would like to also highlight, that I didn't work with EFP project, but with AN5327SW.
Here are some hints for project modifications, that might be useful for you:
/*+++++++++++++++ dual state alignment improvement +++++++++++++++ */
//Old code:
// drvFOC.uDQReq.f16Arg1 = drvFOC.alignVoltage;
// drvFOC.uDQReq.f16Arg2 = FRAC16(0);
//New code:
if (drvFOC.alignCntr>(tU16)(drvFOC.alignCntrInit*ALIGN_D_FACTOR))
{
drvFOC.uDQReq.f16Arg1 = FRAC16(0);
drvFOC.uDQReq.f16Arg2 = drvFOC.alignVoltage;
}
else
{
drvFOC.uDQReq.f16Arg1 = drvFOC.alignVoltage;
drvFOC.uDQReq.f16Arg2 = FRAC16(0);
}
/*+++++++++++++++ dual state alignment improvement end +++++++++++++++ */
void cpmu_init(void)
{
// Wait for stable supply after power up
while (GDUF_GLVLSF)
GDUF_GLVLSF = 1;
CPMUSYNR = 0x00;
CPMUPOSTDIV_POSTDIV = 0;
CPMUREFDIV = 0;
//CPMUSYNR = 0xF1; // 100MHz VCO output
CPMUSYNR = 0x67; // 80MHz VCO output
CPMUIFLG = 0xFF; // clear all flags, especially LOCKIF and OSCIF
// CPMUREFDIV_REFDIV = 3; // 4MHz => 1MHz
// CPMUREFDIV_REFFRQ = 0; // 0 for 1MHz - 2MHz
// CPMUSYNR_SYNDIV = 49; // 100 MHz VCO output
// CPMUSYNR_VCOFRQ = 3;
// CPMUPOSTDIV_POSTDIV = 0; // 100MHz
//
// CPMUOSC_OSCE = 1;
//
CPMUHTCTL_VSEL = 0; //Voltage Access Select Bit
CPMUHTCTL_HTE = 1; //High Temperature Sensor/Bandgap Voltage Enable Bit
//
// // Wait for oscillator to start up (UPOSC=1) and PLL to lock (LOCK=1).
// while (CPMUIFLG_UPOSC == 0) {};
while (CPMUIFLG_LOCK == 0) {};
while(CPMUCLKS != 0b10000000) // After writing CPMUCLKS register, it is strongly recommended to read
{ // back CPMUCLKS register to make sure that write of PLLSEL,
// RTIOSCSEL, COPOSCSEL0 and COPOSCSEL1 was successful.
CPMUCLKS = 0b10000000;
/* ||||||||-------- COPOSCSEL0 - COP Clock Select 0
|||||||--------- RTIOSCSEL - RTI Clock Select
||||||---------- PCE - COP Enable During Pseudo Stop Bit
|||||----------- PRE - RTI Enable During Pseudo Stop Bit
||||------------ COPOSCSEL1 - COP Clock Select 1
|||------------- CSAD - COP in Stop Mode ACLK Disable
||-------------- PSTP - Pseudo Stop Bit
|--------------- PLLSEL - PLL Select Bit
*/
}
CPMURFLG = 0x60; //Clear PORF and LVRF
}
/*++++++++++++ Improved motor startup code update ++++++++++++*/
// Speed FO control mode
// Obsolete code:
// if(cntrState.usrControl.FOCcontrolMode == speedControl)
// drvFOC.currentLoop.pIDQReq->f16Arg2 = GFLIB_ControllerPIpAW(drvFOC.pospeControl.wRotElErr,&drvFOC.speedPI);
// New code:
if(cntrState.usrControl.FOCcontrolMode == speedControl)
{
if(pos_mode == sensorless1)
{
// In Speed control and sensorless mode, FOC Outer Loop (Speed Loop & Field Weakening) output is interconnected with FOC Inner Loop (Current Loop) input
drvFOC.currentLoop.pIDQReq->f16Arg1 = FRAC16(0.0);
drvFOC.currentLoop.pIDQReq->f16Arg2 = GFLIB_ControllerPIpAW(drvFOC.pospeControl.wRotElErr,&drvFOC.speedPI);
}
else
{
// In Speed control and force/tracking mode, required d-axis current is set to Start-up current and q-axis current is set to 0
drvFOC.currentLoop.pIDQReq->f16Arg1 = drvFOC.pospeOpenLoop.iQUpperLimit;
drvFOC.currentLoop.pIDQReq->f16Arg2 = FRAC16(0.0);
}
}
/*++++++++++++ Improved motor startup code update end ++++++++++++*/
After building project, you may edit the debug Configuration. Here is described fast way by editing the current debug Configuration.
Of course, you may create your own Debug Configuration instead of it.
I hope it helps you.
Best regards
RadekS