Why is the CLKOUT not seen on the LPC812 pin?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Why is the CLKOUT not seen on the LPC812 pin?

448件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ucniranjan on Tue Jan 21 03:50:21 MST 2014
Friends,

        I am using the LPCXpresso Board with the IDE. I have a simple program, wherein I redirect the CLKOUT to the pin 7, using the Switch Matrix. My code is below. When I connect the Logic Analyzer to pin 7, I do not see the Clock. What could be wrong? I have used the default libraries of LPCXpresso.

/****************************************************************************/
#include "LPC8xx.h"/* LPC8xx Peripheral Registers */
#include "type.h"

/*****************************************************************************
**   Main Function  main()
******************************************************************************/
int main (void)
{

LPC_SYSCON->SYSAHBCLKCTRL |= ( (0x1 << 7) | (0x1 << 18) );
LPC_SWM->SWM_8BIT_PINASSIGN8 = 0x07FFFF;                        
LPC_SYSCON->SYSAHBCLKCTRL &= ~( (0x1 << 7) | (0x1 << 18) );
        while(1) {  }
}

/*********************************************************************************
                           End Of File
*********************************************************************************/

Thanks in anticipation,
Niranjan
0 件の賞賛
返信
5 返答(返信)

411件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wellsk on Thu Jan 23 17:23:00 MST 2014

Quote:
manual states "no change" for writing a zero. I guess that should be updated.



I had to go back and check this after looking a the UM just to make sure the 0/1 write was really needed. The description for the 0/1 write requirement is actually slightly above the register bit description and is easy to miss.

This register updates the clock source of the CLKOUT pin with the new clock after the
CLKOUTSEL register has been written to. In order for the update to take effect at the input
of the CLKOUT pin, first write a zero to bit 0 of this register, then write a one.

0 件の賞賛
返信

411件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ucniranjan on Wed Jan 22 05:01:45 MST 2014
Thanks very much! The code works now.

Niranjan
0 件の賞賛
返信

411件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by starblue on Wed Jan 22 02:06:40 MST 2014

Quote: wellsk
Note the 0/1 write to CLKOUTUEN is important



Currently the user manual states "no change" for writing a zero. I guess that should be updated.
0 件の賞賛
返信

411件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wellsk on Tue Jan 21 11:31:32 MST 2014
Here is the exact CLKOUT functions (as used in LPCOpen) for the LPC8xx:

/**
 * Clock sources for CLKOUT
 */
typedef enum CHIP_SYSCTL_CLKOUTSRC {
SYSCTL_CLKOUTSRC_IRC = 0,/*!< Internal oscillator for CLKOUT */
SYSCTL_CLKOUTSRC_SYSOSC,/*!< System oscillator for CLKOUT */
SYSCTL_CLKOUTSRC_WDTOSC,/*!< Watchdog oscillator for CLKOUT */
SYSCTL_CLKOUTSRC_MAINSYSCLK,/*!< Main system clock for CLKOUT */
} CHIP_SYSCTL_CLKOUTSRC_T;

/**
 * @briefSet CLKOUT clock source and divider
 * @paramsrc: Clock source for CLKOUT
 * @paramdiv: divider for CLKOUT clock
 * @returnNothing
 * @noteUse 0 to disable, or a divider value of 1 to 255. The CLKOUT clock
 * rate is the clock source divided by the divider. This function will
 * also toggle the clock source update register to update the clock
 * source.
 */
void Chip_Clock_SetCLKOUTSource(CHIP_SYSCTL_CLKOUTSRC_T src, uint32_t div);

/* Set CLKOUT clock source and divider */
void Chip_Clock_SetCLKOUTSource(CHIP_SYSCTL_CLKOUTSRC_T src, uint32_t div)
{
LPC_SYSCTL->CLKOUTSEL = (uint32_t) src;
LPC_SYSCTL->CLKOUTUEN = 0;
LPC_SYSCTL->CLKOUTUEN = 1;
LPC_SYSCTL->CLKOUTDIV = div;
}


Note the 0/1 write to CLKOUTUEN is important. It should hopefully be as simple as:
/* Setup CLKOUT pin for system oscillator with a divider of 1 */
Chip_Clock_SetCLKOUTSource(SYSCTL_CLKOUTSRC_SYSOSC, 1);

0 件の賞賛
返信

411件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Wouter on Tue Jan 21 06:45:47 MST 2014
You have configured the switchmatrix, but you did not yet enable the CLKOUT. The reset value of CLKOUTDIV is 0, meaning it's disabled. By changing the CLKOUTDIV to 1, you should see 12MHz on the CLKOUT pin (IRC clock). You can use register CLKOUTSEL to change the CLKOUT source to e.g. the main clock
0 件の賞賛
返信