I have two questions.
First :.
I have initialized the CPU with:
systemREG1->PLLCTL1 = 0x00000000U
| 0x20000000U
| (3U << 24U)
| 0x00000000U
| (5U << 16U)
| (149U << 8U);
systemREG1->VCLK2R = 0U;
systemREG1->VCLKR = 0U;
so the CPU is running with 100 MHz and the VCLK2 should be 100 MHz too. But VCLK2 is running with 50 MHz
Why ?
Second
I have write a small programm for the NHET
hetREG -> PFR = 0x00000400; /* lr = 16; hr = 1 */
hetREG -> DIR = 0x00001403; /* NHET0,1,10,12 = output */
hetREG -> GCR = 0x00030001; /* Protect Program field */
/* Ignore Suspend */
/* NHET is master */
/* Turn NHET on */
/* L00_0 */
{
0x00002C20,
0x00000000,
0x00000000,
0x00000000
},
/* L01_0 */
{
0x00004000,
0x00404058,
0x00000000,
0x00000000
},
/* L02_0 */
{
0x00006000,
0x00404058,
0x00000000,
0x00000000
},
/* L03_0 */
{
0x00008000,
0x00404058,
0x00000000,
0x00000000
},
/* L04_0 */
{
0x00000000,
0x00404058,
0x00000000,
0x00000000
}
void main(void)
{
/* USER CODE BEGIN (3) */
volatile unsigned int a;
volatile unsigned int wait;
e_HETPROGRAM0_UN.Program0_ST.L00_0.cnt.max = MAXVALUE;
e_HETPROGRAM0_UN.Program0_ST.L01_0.mcmp.pin_select = 0;
e_HETPROGRAM0_UN.Program0_ST.L02_0.mcmp.pin_select = 3;
e_HETPROGRAM0_UN.Program0_ST.L03_0.mcmp.pin_select = 10;
e_HETPROGRAM0_UN.Program0_ST.L04_0.mcmp.pin_select = 12;
/* Output a PWM with duty cycle update (25% .. 75%) */
while(1)
{
hetREG -> DOUT = 0;
for(a=MAXVALUE; a>0x0; a-=50)
{
e_HETPROGRAM0_UN.Program0_ST.L01_0.mcmp.data = a;
e_HETPROGRAM0_UN.Program0_ST.L02_0.mcmp.data = MAXVALUE-a;
e_HETPROGRAM0_UN.Program0_ST.L03_0.mcmp.data = a;
e_HETPROGRAM0_UN.Program0_ST.L04_0.mcmp.data = a;
/* wait some time before doing the next duty cycle update */
for(wait=0;wait<20000;wait++);
}
for(a=0x0; a<MAXVALUE; a+=50)
{
e_HETPROGRAM0_UN.Program0_ST.L01_0.mcmp.data = a;
e_HETPROGRAM0_UN.Program0_ST.L02_0.mcmp.data = MAXVALUE-a;
e_HETPROGRAM0_UN.Program0_ST.L03_0.mcmp.data = a;
e_HETPROGRAM0_UN.Program0_ST.L04_0.mcmp.data = a;
/* wait some time before doing the next duty cycle update */
for(wait=0;wait<20000;wait++);
}
}
/* USER CODE END */
}
Now my question : Why the NHET output 10 and 12 has no full PWM from 0 to 100 percent