微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI无线射频设计 > CC2541,外部晶振失败后,如何重启外部晶振

CC2541,外部晶振失败后,如何重启外部晶振

时间:12-23 整理:3721RD 点击:

外部32.768khz晶振因焊接问题,导致外部晶振失效,重新焊好之后发现单片机并没有重新使用外部晶振,是否是进入了内部晶振模式?如何恢复呢?

非常感谢!

// set 32kHz OSC and wait until it is stable #define SET_32KHZ_OSC() \ { \ CLKCONCMD = (CLKCONCMD & ~0x80) | OSC_32KHZ; \ while ( (CLKCONSTA & 0x80) != OSC_32KHZ ); \ }

默认是使用外部的32k晶振的,您可以重新烧录程序试试。

#define BV(n) (1 << (n))


#define XOSC_STB BV(6) /* XOSC: powered, stable=1 */
#define HFRC_STB BV(5) /* HFRCOSC: powered, stable=1 */
/* CLKCONCMD bit definitions */
#define OSC BV(6)
#define TICKSPD(x) (x << 3)
#define CLKSPD(x) (x << 0)
#define CLKCONCMD_32MHZ (0)
#define CLKCONCMD_16MHZ (CLKSPD(1) | TICKSPD(1) | OSC)
#define OSC_PD BV(2) /* Idle Osc: powered down=1 */

#define EXTERNAL_CRYSTAL_OSC 0x00 // external 32kHz XOSC
#define INTERNAL_RC_OSC 0x80 // internal 32kHz RCOSC

// For non-USB, assume external, unless an internal crystal is explicitly indicated.
#define XOSC32K_INSTALLED TRUE //FALSE TRUE
#if !defined (XOSC32K_INSTALLED) || (defined (XOSC32K_INSTALLED) && (XOSC32K_INSTALLED == TRUE))
#define OSC_32KHZ EXTERNAL_CRYSTAL_OSC 
#else
#define OSC_32KHZ INTERNAL_RC_OSC 
#endif

//START_HSOSC_XOSC
SLEEPCMD &= ~OSC_PD; /* start 16MHz RCOSC & 32MHz XOSC */
while (!(SLEEPSTA & XOSC_STB)); /* wait for stable 32MHz XOSC */

//SET_OSC_TO_HSOSC
CLKCONCMD = (CLKCONCMD & 0x80) | CLKCONCMD_16MHZ;
while ( (CLKCONSTA & ~0x80) != CLKCONCMD_16MHZ );

//SET_32KHZ_OSC
CLKCONCMD = (CLKCONCMD & ~0x80) | OSC_32KHZ;
while ( (CLKCONSTA & 0x80) != OSC_32KHZ );

//SET_OSC_TO_XOSC
CLKCONCMD = (CLKCONCMD & 0x80) | CLKCONCMD_32MHZ;
while ( (CLKCONSTA & ~0x80) != CLKCONCMD_32MHZ );

//STOP_HSOSC
SLEEPCMD |= OSC_PD; /* stop 16MHz RCOSC */

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top