TI中文支持网
TI专业的中文技术问题搜集分享网站

有关于MSP430FR4133双边沿触发的程序问题

我想让它在上升沿的时候计数加一,下降沿的时候技术加一,但是程序一直运行的不对。恳请各位大牛帮忙看一看哪里有问题,谢谢

下面是程序

#include <msp430.h>
#include <driverlib.h>
#include "ADCDriver.h"
#include "hal_LCD.h"
#include <math.h>
#define BIT0 (0x0001u)
#define BIT1 (0x0002u)
#define BIT2 (0x0004u)
#define BIT3 (0x0008u)
#define BIT4 (0x0010u)
#define BIT5 (0x0020u)
#define BIT6 (0x0040u)
#define BIT7 (0x0080u)

volatile unsigned int analogue_val_ = 0;
unsigned int count = 0;
unsigned int count1 = 0;
unsigned int count2 = 0;
unsigned int analg= 1;
unsigned int analg1= 1;
unsigned int analg2= 1;

void init_TA1(void) //initial TA1
{
P1DIR=0xf0;
P1SEL0 = BIT2; TA1CTL = TACLR+TASSEL_2+TAIE+MC_2+ID_2;
TA1CCTL1 = CM_1+SCS+CCIS_0+CAP+CCIE;

}
/***********************************************************
capture************************************************************/
#pragma vector = TIMER0_A1_VECTOR//interrupt
__interrupt void Timer_A(void)
{ switch(TA0IV)

{ case 2: if(TA1CCTL1&CM0)

{ //TACTL|=TACLR;
TA1CCTL1=(TA1CCTL1&(~CM0))|CM1;

count++;
}
else if (TA1CCTL1&CM1)

{ TA1CCTL1=(TA1CCTL1&(~CM1))|CM0; count++;
} break;
default:
break;
}}

int main(void)
{
WDTCTL = WDTPW | WDTHOLD;// Stop watchdog timer
Init_LCD();//configure and turn LCD
PMM_unlockLPM5();
__enable_interrupt();

clearLCD();
init_TA1();
LCD_E_selectDisplayMemory(LCD_E_BASE, LCD_E_DISPLAYSOURCE_MEMORY);
//ADCCTL0 |= ADCENC | ADCSC; // Sampling and conversion start
while(1)
{
if(TA1CCTL1&CM0)

{ //TACTL|=TACLR;
count=++;
}
else if (TA1CCTL1&CM1)

{ count=++;
} showChar(((count / 100000) % 10) + 48,pos1);
showChar(((count / 10000) % 10) + 48,pos2);
showChar(((count / 1000) % 10) + 48,pos3);
showChar(((count / 100) % 10) + 48,pos4); showChar(((count / 10) % 10) + 48,pos5);
showChar(((count / 1) % 10) + 48,pos6);
}
}

Jacky Xu:

能把要求说清楚点么?你想用输入捕获模式下,上下沿都捕获,然后在捕获中断里面让你的count都累加?

赞(0)
未经允许不得转载:TI中文支持网 » 有关于MSP430FR4133双边沿触发的程序问题
分享到: 更多 (0)