1296 views|0 replies

3836

Posts

19

Resources
The OP
 

Talk about MSP430G2553 clock and clock interrupt [Copy link]

#include "msp430G2553.h" //************* *Main function****************************** void main() { WDTCTL = WDTPW + WDTHOLD; // Stop WDT [ color=#252525] BCSCTL1 = CALBC1_1MHZ; //The clock is 1M, and the courses are 8M, 12M and 16M DCOCTL = CALDCO_1MHZ; //Same as above (and set at the same time) BCSCTL2 |=SELM_1+DIVM_3;/ /SELM_1 clock source selection, 0 and 1 are DCOCLK, // 2 is XT2CLK/LFXTCLK, 3 is LFXTCLK //DIVM_1, for the selected clock division, 0 is no division, 1 is 2 division, 2 is 4 division, 3 is 8 division[ /color] //////////// P1DIR|=0x41; //P1.6 and P1.0 are outputs, controlling LED P1OUT |=0x01; P1OUT &=~0x40; ////////////////// TACTL |= TASSEL_2+ID_3+MC_1; //TASSEL_x counter clock source selection, x=0, external clock TACLK, 1 selects ACLK, 2 selects SMCLK, 3 selects external clock // ID_x It is the frequency division selection, x=0 is no frequency division, 1 is 2 frequency division, 2 is 4 frequency division, 3 is 8 frequency division (125K) 18px] // MC_x is the counting mode, x=0, stop, 1 is up to the value of CCR0, 2 is continuous to the full 0xffff, / /3 Increase and decrease the count, first increase to the value of CCR0, then decrease to 0 TACCR0 =25000; //Count to 2500, about 20ms TACCTL0 |= CCIE; // CCR0 interrupt enabled [color=#252525 ] _BIS_SR(GIE); //Enable total interrupt while(1); } #pragma vector=TIMER0_A0_VECTOR __interrupt void Timer_A(void) { //TACCTL0&=~ CCIE; //Turn off interrupts static int cc=0; cc+=1; if(cc==20) //1s=1000ms=20*50 Timing { P1OUT^=0x41; //P1.6 LED inversion cc=0; } [ size=18px]}
This post is from Microcontroller MCU
 

Guess Your Favourite
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list