最新回复
#include "msp430g2553.h"#include "delay.h"
void sys_init(void){ DCOCTL = CALDCO_16MHZ; BCSCTL1 = CALBC1_16MHZ; }
void io_init(void){ P1DIR = 0; P1DIR |= BIT4 + BIT6; P1SEL |= BIT1;}void cap_init(void){ TACTL |= TASSEL_2 + MC_2 + TACLR; //MCLK , CONTINUE , CLEAR TACCTL0 |= CM_1 + SCS + CAP + CCIE + CCIS_0; // rising edge , synchronous , capture , interupt enable }
void main( void ){ // Stop watchdog timer to prevent time out reset WDTCTL = WDTPW + WDTHOLD; sys_init(); io_init(); cap_init(); __enable_interrupt(); while(1) { P1OUT ^= BIT6; delay_ms(30); }}
#pragma vector = TIMER0_A0_VECTOR__interrupt void capture(void){ P1OUT ^= BIT4; // 输出频率是捕获频率的一半}
详情
回复
发表于 2012-7-17 21:23
| |
|
|
| |
|
|
回复 沙发 ltbytyn 的帖子
此帖出自微控制器 MCU论坛
| ||
|
||
此帖出自微控制器 MCU论坛
| ||
|
||
曾经的版主且威望大于2000,或对EEWORLD论坛有突出贡献的坛友
论坛测评队员
EEWorld Datasheet 技术支持