Demo entry 6754860

Sincar

   

Submitted by anonymous on Jul 23, 2018 at 05:25
Language: C++. Code size: 1.7 kB.

#include <msp430.h>
int main(void)
{
  /*初始化时钟,高速外部晶振*/
  P5SEL |= BIT2|BIT3; 				
  UCSCTL6 &= ~XT2OFF; 					
  UCSCTL4 = UCSCTL4&(~(SELA_7))|SELA_1;  
  UCSCTL3 |= SELREF_2;                  
  UCSCTL4 = UCSCTL4&(~(SELS_7|SELM_7))|SELS_5|SELM_5;    
  /*关闭看门狗*/
  WDTCTL = WDTPW + WDTHOLD;    
  /*初始化GPIO*/
  P2DIR |= BIT4;                       		
  P2SEL |= BIT4;                       		
  /*配置定时器A*/
  TA2CCR0 = 40;                             
  TA2CCTL1 = OUTMOD_6;                      
  TA2CCR1 = 20;                             
  TA2CTL = TASSEL_2 + MC_3 + TACLR;         
  /*清楚三类时钟标志位*/
  while (SFRIFG1 & OFIFG){
        UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG);       
        SFRIFG1 &= ~OFIFG;                  
      }
  __bis_SR_register(LPM0_bits);           
  __no_operation();                         
}
#include <msp430.h>
int main(void)
{
  /*初始化时钟,高速外部晶振*/
  P5SEL |= BIT2|BIT3; 				
  UCSCTL6 &= ~XT2OFF; 					
  UCSCTL4 = UCSCTL4&(~(SELA_7))|SELA_1;  
  UCSCTL3 |= SELREF_2;                  
  UCSCTL4 = UCSCTL4&(~(SELS_7|SELM_7))|SELS_5|SELM_5;    
  /*关闭看门狗*/
  WDTCTL = WDTPW + WDTHOLD;    
  /*初始化GPIO*/
  P2DIR |= BIT4;                       		
  P2SEL |= BIT4;                       		
  /*配置定时器A*/
  TA2CCR0 = 40;                             
  TA2CCTL1 = OUTMOD_6;                      
  TA2CCR1 = 20;                             
  TA2CTL = TASSEL_2 + MC_3 + TACLR;         
  /*清楚三类时钟标志位*/
  while (SFRIFG1 & OFIFG){
        UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG);       
        SFRIFG1 &= ~OFIFG;                  
      }
  __bis_SR_register(LPM0_bits);           
  __no_operation();                         
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).