// 同时输出两个方波
- #include <msp430g2553.h>
- int main( void )
- {
- // Stop watchdog timer to prevent time out reset
- WDTCTL = WDTPW + WDTHOLD;
- P1DIR |= BIT1 + BIT2; // p1.1 p1.2
- P1SEL |= BIT1 + BIT2;
- //P2DIR |= BIT0;
- // P2SEL |= BIT0;
- CCTL0 = OUTMOD_4;
- // CCTL1 = OUTMOD_4; // toggle
- CCR0 = 50-1;
- // CCR1 = 10-1;
- TACTL = TASSEL_2 + MC_1; // SMCLK + UP MODE
- _BIS_SR(CPUOFF);
- return 0;
- }
复制代码
通过示波器,看到p1.1输出了10 000hz方波,看到p1.2后面写着TA0.1,原以为也能这样输出一个方波,却没有实现。后来这样实现了。
/ 实验目的:输出频率为10、50kHz的方波
/*
f = 10^4hz T = 10^(-4)s= 100 / 1000 000
*/
- #include <msp430g2553.h>
- int main( void )
- {
- // Stop watchdog timer to prevent time out reset
- WDTCTL = WDTPW + WDTHOLD;
- P1DIR |= BIT2;
- P1SEL |= BIT2;
- CCR0 = 20-1; // 100 / 20
- CCTL1 = OUTMOD_7; // CCR1 RESET/SET
- CCR1 = 10; // 50 / 10
- TACTL = TASSEL_2 + MC_1; // smclk + up
- _BIS_SR(CPUOFF);
- return 0;
- }
复制代码
可是第一种办法为什么不行呢?TA0.1又代表什么呢?
此帖出自
小平头技术问答
您好,我改了改
- // f= 1000 000 / 20 = 50000 hz t = 20us
- #include <msp430g2553.h>
- int main( void )
- {
- // Stop watchdog timer to prevent time out reset
- WDTCTL = WDTPW + WDTHOLD;
- P1DIR |=BIT2; // p1.1 p1.2
- P1SEL |=BIT2;
- //CCTL0 = OUTMOD_4; // toggle
- //CCR0 = 10-1;
-
- CCTL1 = OUTMOD_4;
- CCR1 = 10-1;
- TACTL = TASSEL_2 + MC_1; // SMCLK + UP MODE
- _BIS_SR(CPUOFF);
- return 0;
- }
复制代码这样写 p12还是无法输出的。我再看看官方例程吧一周热门 更多>