现在显示出来.....cm 定时器A没有进入中断 我想知道问题出在哪里了,怎么改,小白一个 急急急,毕业设计
#include <msp430g2553.h>
#include<stdio.h>
#include<math.h>
unsigned int result1_start,result1_end;
unsigned char index=0;
unsigned int temp;
float distance;
unsigned char juli0_cm;
unsigned char juli1_cm;
unsigned char juli2_cm;
unsigned char juli4_cm;
unsigned char font6x8[][6] = {
{0x00,0x00,0x60,0x60,0x00,0x00},//.(0)
{0x00,0x3E,0x51,0x49,0x45,0x3E},//0(1)
{0x00,0x00,0x42,0x7F,0x40,0x00},//1(2)
{0x00,0x42,0x61,0x51,0x49,0x46},//2(3)
{0x00,0x21,0x41,0x45,0x4B,0x31},//3(4)
{0x00,0x18,0x14,0x12,0x7F,0x10},//4(5)
{0x00,0x27,0x45,0x45,0x45,0x39},//5(6)
{0x00,0x3C,0x4A,0x49,0x49,0x30},//6(7)
{0x00,0x01,0x71,0x09,0x05,0x03},//7(8)
{0x00,0x36,0x49,0x49,0x49,0x36},//8(9)
{0x00,0x06,0x49,0x49,0x29,0x1E},//9(10)
{0x00,0x38,0x44,0x44,0x44,0x20},//c(11)
{0x00,0x7E,0x02,0x0C,0x02,0x7C},//m(12)
};
void CloseWDTCTL()
{
WDTCTL=WDTPW+WDTHOLD;
}
void ClockInit()
{
if (CALBC1_1MHZ ==0XFF || CALDCO_1MHZ == 0XFF)
{ P1OUT = 0X01; }
BCSCTL1=CALBC1_1MHZ;
DCOCTL=CALDCO_1MHZ;
}
void PortInit()
{
P2DIR &=~BIT1;
P2SEL |=BIT1;
P2DIR |=BIT0;
}
void Timer1Init()
{
TACCTL1=CAP+CCIS_0+CM_3+CCIE+SCS;
TA1CTL|=TASSEL_2+ID_0+MC_2+TAIE+TACLR;
TACCR1=0;
TACTL &=~CCIFG;
}
void send_15us()
{
P2OUT &=~BIT0;
delay_nus(20);
P2OUT |=BIT0;
delay_nus(15);
P2OUT &=~BIT0;
}
void main(void)
{
CloseWDTCTL();
P1DIR=0x7f;
P1OUT=0;
PortInit();
ClockInit();
delay_nms(200);
LCD_Init();
Timer1Init();
display_char(1,1,juli0_cm);
display_char(2,1,juli1_cm);
display_char(3,1,juli2_cm);
display_char(4,1,0x00);
display_char(5,1,juli4_cm);
display_char(6,1,0x0b);
display_char(7,1,0x0c);
_EINT();
while(1)
{
send_15us();
delay_nms(100);
}
}
#pragma vector=TIMER1_A3_VECTOR
__interrupt void TAIV_ISR(void)
{
switch(TAIV)
{
case 2:
if(TACCTL1&CCI)
{
result1_start=CCR1;
index=0;
break;
}
else
{
unsigned int juli;
result1_end=CCR1;
if(result1_end>result1_start)
temp=result1_end-result1_start;
else
temp=result1_end+index*65535-result1_start;
distance=temp*340/10000/2;
juli=distance*10+1/2;
juli0_cm=juli/1000+0x01;
juli1_cm=juli%1000/100+0x01;
juli2_cm=juli%100/10+0x01;
juli4_cm=juli%10+0x01;
index=0;
break;
}
case 10:index++;break;
default:break;
}
TACCTL1 &=~COV;
}
此帖出自
小平头技术问答
一周热门 更多>