Cyclone LC can successfully write the program, but during the program run, the value of register CPMUVREGCTL cannot be initialized to 0x82, and the external BJT cannot be opened.
The PE micro can successfully write the program, but during the program run, the CPMUVREGCTL register value is initialized to 0x82, and the external BJT can be opened.
Have you tried debugging the program in CodeWarrior? Are you able to step through your line of code and make sure the CPMUVREGCTL is initialized to 0x82?
Yes, in CodeWarrior, using the PE micre tool for single-step debugging, BJT is not turned on when the CPMUVREGCTL assignment statement is not executed before, and BJT is turned on when the CPMUVREGCTL assignment statement is executed.
Please try the following:
1. disconnect the ZVL chip from the Cyclone LC.
2. Power Cycle the ZVL chip.
3. Check if the external BJT.
* Use the Cyclone LC tool to refresh the data successfully
* The ZVL chip is powered on
* External BJT is not open
I tried the above steps several times, but failed to open the BJT.
Here is the initial part of the software:
/* ECLKCTL: NECLK=1,??=0,??=0,??=0,??=0,??=0,??=0,??=0 */
setReg8(ECLKCTL, 0x80U);
/* System clock initialization */
/* CPMUPROT: ??=0,??=0,??=1,??=0,??=0,??=1,??=1,PROT=0 */
setReg8(CPMUPROT, 0x26U); /* Disable protection of clock configuration registers */
/* 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=0 */
setReg8(CPMUPOSTDIV, 0x00U); /* 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=1,SYNDIV5=0,SYNDIV4=1,SYNDIV3=1,SYNDIV2=1,SYNDIV1=1,SYNDIV0=1 */
setReg8(CPMUSYNR, 0x5FU); /* Set the multiplier register */
while(CPMUIFLG_LOCK == 0U) { /* Wait until the PLL is within the desired tolerance of the target frequency */
}
/* CPMUPROT: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,PROT=0 */
setReg8(CPMUPROT, 0x00U); /* Enable protection of clock configuration registers */
/* CPMUCOP: RSBCK=1,WRTMASK=1 */
setReg8Bits(CPMUCOP, 0x60U);
/* CPMUHTCTL: ??=0,??=0,VSEL=0,??=0,HTE=0,HTDS=0,HTIE=0,HTIF=0 */
setReg8(CPMUHTCTL, 0x00U);
/* CPMUVREGCTL: VREG5VEN=1,??=0,??=0,??=0,??=0,??=0,EXTXON=1,INTXON=0 */
setReg8(CPMUVREGCTL, 0x82U);
Is there a problem with this initialization?
What makes me confused is that the use of PE micro tools to refresh, can open the external BJT?
Hi Lin,
Is there a difference between what you program using the Cyclone LC and when you are using CodeWarrior to debug? Did you make sure to rebuild your elf file?