In the LPC11A14, I need to use the on chip pull-up resistor on my GPIO P0_28 as input port. It works good. But it fail when I configure de PLL output as my main clock source.
MAINCLKUEN_bit.ENA = 0; // in this point the pull-up is working very good!
MAINCLKSEL_bit.SEL = 3; // in this point the pull-up is working very good!
MAINCLKUEN_bit.ENA = 1; // after execution of this code, the pull-up is no more working.
To see the pull-up active, I used a voltmeter in the P0_28 pin. When it is working, I see 2,8V (I expected 3,3V, but with 2,8V is working). But when it is not working, I see 0,6V in this pin.
I used the function InitClock to configure the main clock and the PLL. If I change the divisor (second parameter), the voltage in the pin changes too.
For more informations, my complete code is:
void main(void)
{
//GPIO configuration:
P0DIR_bit.DIR28=0;
IOCON_P0_28_bit.FUNC=0;
IOCON_P0_28_bit.MODE=2;
//Configuration of clock
InitClock(240MHZ, 5); //<<< PROBLEM INSIDE THIS FUNCTION
while(true) { /* my code */ }
}
void InitClock(Int32U pllclock, Int32U ahbdiv) //page. 27
{
/* Enable XTAL Oscilator */
PDRUNCFG_bit.XTAL_PD = 0;
/* Enable Internal RC oscilator */
PDRUNCFG_bit.IRC_PD = 0;
/* Select internal RC oscilator for SYS clock source */
MAINCLKUEN_bit.ENA = 0;
MAINCLKSEL_bit.SEL = 0;
MAINCLKUEN_bit.ENA = 1;
/* Configure System PLL */
/* Power-down System PLL */
PDRUNCFG_bit.SYSPLL_PD = 1;
/* Select XTAL Oscilator for SYS PLL input */
SYSPLLCLKUEN_bit.ENA = 0;
SYSPLLCLKSEL_bit.SEL = 0; //0=IRC, 1=XTAL, 2=CLKIN pin
SYSPLLCLKUEN_bit.ENA = 1;
/* Calculate M */
Int32U m = pllclock/(XTAL_OSC_FREQ*(2*2)) - 1;
assert(m<32);
/* Configure PLL frequency */
SYSPLLCTRL_bit.MSEL = m;
SYSPLLCTRL_bit.PSEL = 1;
/* Power-up PLL */
PDRUNCFG_bit.SYSPLL_PD = 0;
/* Set System AHB Clock divider */
SYSAHBCLKDIV_bit.DIV = ahbdiv;
/* Wait until PLL locks */
while(!(SYSPLLSTAT_bit.LOCK));
/* Select System PLL Output for SYS clock source */ //page. 20
MAINCLKUEN_bit.ENA = 0;
MAINCLKSEL_bit.SEL = 3;
MAINCLKUEN_bit.ENA = 1; //<<< PROBLEM AFTER THIS EXECUTION
}
已解决! 转到解答。
I found the solution. I changed the microcontroler and now is working.
Thanks for all.
Henry