AnsweredAssumed Answered

LPC4357 MOTOCONPWM MIC0-2 external counter max frequence

Question asked by sky sky on Mar 10, 2017
Latest reply on Mar 12, 2017 by jeremyzhou

i want to use the pin-MIC0 of LPC4357 MOTOCONPWM to counter a external signal's frequence.

and i use the way of External event counting (Counter mode),the pin MCI0 is used to input the Signal to be measured。

then set a match value in counter mode,then play the role of frequency division,(100 prescaler-Check the MOTORCONPWM's output pin MCOA0)。

In order to test whether this method is effective,i use CLK0(IDVE clock)clock connect to MCI0。

So,i find a error:

1.CLK0 be set to 2MHZ,the MIC counter is correct,the MCOA0 output 20KHZ

2.CLK0 be set to 4MHZ,the MIC counter is corrent,the MCOA0 output 40KHZ

3.CLK0 be set to 8MHZ,the MIC counter is error,the MCOA0 output also about 40KHZ 

 

my code such follow:

 

LPC_CCU1->CLK_APB1_MOTOCONPWM_CFG = 0x7;

LPC_RGU->RESET_CTRL1 = 1 << 6; //MOTOCONPWM_RST
while(!(LPC_RGU->RESET_ACTIVE_STATUS1 & (1 << 6)));

LPC_SCU->SFSP8_2 = ((1 << 4) | (1<<6) | (1<<7) | 3);//   MIC0
LPC_SCU->SFSP9_3 = 1;      //MCOA0
LPC_SCU->SFSP9_4 = 1;   //MCOB0

LPC_MCPWM->CON_CLR = 0xffffffff;
LPC_MCPWM->CNTCON_SET = (1 << 29) | 1; //channel0 counter / rising

LPC_MCPWM->LIM0 = 100;      //100 prescaler
LPC_MCPWM->MAT0 = 50;

 

 

thank you very much

Outcomes