Hello TI employee,
I'm working on UART issue, I need the whole system sleep in LPM3 to save power consuption ,but I need it wake up form LPM3 and receive data from the UART bus(57600bps)as soon as possible, or the first byte will corrupt. I remember the DCO of MSP430s can wake up from LPM4 in 5 us. so I thinlk it 's a piece of cake for MSP430F6736 to do this job , The fact is it fails :( . The first guess flash in my head is the Start-up time may be too long ,so I do the following experment.
PJ.0 -----second fuction----SMCLK---output souced from DCO
P1.3 ----IO
#include "msp430F6736.h" #include "HAL_PMM.h" u16_t VcoreSettingFlag; void init_SysClk(void) { u08_t VcoreSettingFlag; PJSEL |=BIT0; PJDIR |= BIT0; // SetVCore()-----TI lib VcoreSettingFlag =SetVCore(PMMCOREV_3); if( VcoreSettingFlag==0) { // OK _NOP(); _NOP(); } //刚开始设定晶振失效不会引起不可屏蔽中断 SFRIE1 &=~OFIE; UCSCTL0 = 0; UCSCTL1 = DCORSEL_6; //FLLD =2 FLLN=255 UCSCTL2 = FLLD_1 + 255; UCSCTL3 = 0; UCSCTL4 = SELA__XT1CLK + SELS__DCOCLK + SELM__DCOCLK; //UCSCTL4 = SELA__XT1CLK + SELS__DCOCLKDIV + SELM__DCOCLKDIV; //MCLK SMCLK ACLK都不分频 UCSCTL5 = DIVM_0 + DIVS_0 + DIVA_0; //使用增强型驱动晶振快速起振 UCSCTL6 = XT2OFF + XT1DRIVE_3; //进入LPMx之后直接关闭时钟 不允许模块有要求的时候 就不允许睡眠的情况 UCSCTL8 &=~( ACLKREQEN | MCLKREQEN | SMCLKREQEN | MODOSCREQEN); UCSCTL8 |=SMCLKREQEN; do{ UCSCTL7 &=~(XT2OFFG | XT1LFOFFG | DCOFFG); SFRIFG1 &=~ OFIFG; __delay_cycles(1000); }while(SFRIFG1 & OFIFG); _NOP(); _NOP(); //跳出OFIFG检测循环后,需要延时一段时间,再次检测, //以充分认证晶振确实已经稳定工作 __delay_cycles(1000); _NOP(); //起振之后,可以关闭增强型驱动,以降低功耗。 UCSCTL6 = XT2OFF; do{ UCSCTL7 &=~(XT2OFFG | XT1LFOFFG | DCOFFG); SFRIFG1 &=~ OFIFG; __delay_cycles(500); }while(SFRIFG1 & OFIFG); //设定晶振失效引起不可屏蔽中断 //----第一次禁止是因为晶振刚开始工作,这个需要时间,晶振失效 //导致相应的OFIFGG属于正常起振过程;但是晶振已经正常工作后,再次 //晶振失效,这个就属于不正常现象,需要应用代码介入,具体处理 //由用户自己决定 SFRIE1 |=OFIE; _NOP(); _EINT(); } #pragma vector = PORT1_VECTOR __interrupt void TxRxIo_Isr(void) { P1IFG &=~(BIT2+BIT3); LPM3_EXIT; } void main( void ) { // Stop watchdog timer to prevent time out reset WDTCTL = WDTPW + WDTHOLD; init_SysClk(); P1DIR &=~BIT3; P1SEL &= ~BIT3; P1IES |= BIT3; P1IE |= BIT3; while(1) { LPM3;; _NOP(); _NOP(); __delay_cycles(9999999); __delay_cycles(9999999); _NOP(); _NOP(); } }
The yellow line is P1.3 , the green line is PJ.0 -----SMCLK
the result is that DCO nearly costs 140us to start up, Am I get sth wrong or I miss sth ? Need your help , Thanks in advance.