This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] MSP430F2616:计时器 A 中断仅用于102个计数、然后它停止中断处理器

Guru**** 1863650 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/610974/msp430f2616-timer-a-interrupt-is-working-only-for-102-counts-and-then-it-stops-interrupting-the-processor

器件型号:MSP430F2616

端口1位7用于检查中断。

#include
#define DR P5OUT = P5OUT | BIT7 //将 RS 定义为高电平
#define CWR P5OUT = P5OUT &(~BIT7)//将 RS 定义为低电平
#define READ P5OUT = P5OUT | BIT5 //定义用于读取的读取信号 R/W = 1
#define WRITE P5OUT = P5OUT &(~BIT5)//定义写入信号 R/W = 0进行写入
#define ENABLE_HIGH P5OUT = P5OUT | BIT6 //定义使能高电平信号
#define ENABLE_LOW P5OUT = P5OUT &(~BIT6)//定义使能低电平信号
void check_busy (void);
void data_read (void);
void delay (unsigned int wt);
void init (void);
void init_lcd (void);
void wr_lcd_cw (unsigned char lcd_cmd);
void wr_lcdw (unsigned char wr_lcd_dw);
void lcd_msg (unsigned char *ch);
volatile unsigned int a=0、b=0、c=0、d=0、e、f、sec1=2、As;

//__interrupt void Timer_A (void);
//PIN R/W =
/*
* main.c
*
void count_increment (void);

unsigned char array[10]={"0123456789"};


int main (void){

volatile unsigned int i;
WDTCTL = WDTPW | WDTHOLD;//停止看门狗计时器
init();
init_lcd();

延迟(1000);
P1OUT &=~BIT7;

WR_LCD_CW (0x80);
lcd_msg ((unsigned char *)"up count");

while (1)

for (a=0;a<10;a++)

WR_LCD_CW (0xC0);
WR_LCD_dw (array[A]);
for (b=0;b<10;b++)

WR_LCD_CW (0xC1);
WR_LCD_dw (array[b]);
for (c=0;c<10;c++)

WR_LCD_CW (0xC2);
WR_LCD_dw (array[c]);
for (d=0;d<10;d++)

WR_LCD_CW (0xc3);
WR_LCD_dw (array[d]);
P1OUT ^= BIT5|BIT6;
延迟(1000);//使用异或切换 P1.0
//delay (1000)//while (~(TAIV));1秒延迟




如果(AS)

AS = 0;
// count_increment ();




void count_increment (void)(空)

/*if (array[d]<10)

D++;
WR_LCD_CW (0xc3);
WR_LCD_dw (array[d]);

否则 if (array[c]<10)

C++;
WR_LCD_CW (0xC2);
WR_LCD_dw (array[c]);

否则 if (array[b]<10)

B++;
WR_LCD_CW (0xc1);
WR_LCD_dw (array[b]);

否则 if (array[a]<10)

A++;
WR_LCD_CW (0xc0);
WR_LCD_dw (array[A]);

*}*/

P1OUT ^= BIT7;
sec1 = 2;

空延迟(unsigned int wt)

unsigned int k;
volatile unsigned int i;
for (k=0;k <= wt;k++)

//for (i = 0;i <= 800;i++);
_delay_cycles (16000);


void lcd_msg (无符号字符*ch)

while (*ch!='0')

WR_LCD_dw (*通道);
CH++;


void wr_lcd_cw (unsigned char lcd_cmd){
check_busy();
P4OUT=LCD_cmd;
CWR;
写入;
ENABLE_HIGH;//EN=1
延迟(3);
ENABLE_LOW;//EN=0

void wr_lcdw (unsigned char lcd_data){
check_busy();
P4OUT=LCD_DATA;
博士;
写入;
ENABLE_HIGH;//EN=1
延迟(3);
ENABLE_LOW;//EN=0

void init_lcd (void)

WR_LCD_CW (0x38);延迟(10);// 8位模式下的 LCD
WR_LCD_CW (0x0E);延迟(10);// 8位模式下的 LCD
WR_LCD_CW (0x06);延迟(10);// 8位模式下的 LCD
WR_LCD_CW (0x01);延迟(10);// 8位模式下的 LCD

//lcd_content (0x02);//返回主页位置

空 init (空)

DCOCTL = 0x60;
BCSCTL1 = 0xFF;
BCSCTL2 = 0x00;
BCSCTL3 = 0x20;
IFG1=0x00;
IFG2=0x00;

TACTL = 0x01D0;
TACCTL0 = CCIE;// CCR0中断被启用
TACCR0 = 16000;

P1SEL=0;
P5SEL=0;
P4SEL=0;

P1DIR=0xff;
P4DIR=0xff;
P5DIR=0xff;
//初始化未使用的端口以节省功耗
P2DIR=0xFF;
P3DIR=0xFF;
P6DIR=0xFF;
P7DIR=0xFF;
P8DIR=0xFF;
P2OUT=0x00;
P3OUT=0x00;
P6OUT=0x00;
P7OUT=0x00;
P8OUT=0x00;

P1DIR |= BIT5|BIT6;//将 P4位5和6设置为输出方向
P4DIR = 0xFF;//将端口4设置为输出
P5DIR = 0xFF;//将端口5设置为输出
P4OUT = 0x00;
P5OUT = 0x00;
_bis_SR_register (GIE);

空 CHECK_BUSY (空)

P4DIR &=~(BIT7);//将 P2.3作为输入
data_read();
while (((P4IN & BIT7)= 1)

data_read();

P4DIR |= BIT7;//将 P2.3作为输出

void data_read (void)

CWR;
读;
ENABLE_LOW;
延迟(2);
ENABLE_HIGH;

// Timer B0中断服务例程
#pragma vector=TIMERA0_vector
_interrupt void Timer_A (void)


第1节----
//P1OUT^= BIT7;
if (sec1==0)

count_increment ();

AS = 1;
//P1OUT ^= BIT5|BIT6|BIT7;//切换 P1.0
TACCR0 += 16000;//将偏移添加到 CCR0
//TACTL &=~TAIFG;

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    >DCOCTL = 0x60;
    >BCSCTL1=0xFF;
    >BCSCTL2 = 0x00;
    >BCSCTL3 = 0x20;

    这些设置似乎有问题。  

    1)在 DCO 表(SLAS541K 第42页)上进行 I squared 时、您可能会超频。

    2) 2)您要将 ACLK 设置为将 TimerA 驱动到外部高频晶体。 由于您从 DCO 运行 S/MCLK、我猜是晶体不在那里、并且您遇到时钟故障、该故障会停止计时器。

    您不使用 CALDCO_16MHz 和 CALBC1_16MHz 是否有原因?

    此外、我希望使用位名称进行编码会使重置变得更容易。

    未经请求:

    >while (((P4IN & BIT7)=1)

    此条件始终为 false。 尝试:

    >while ((P4IN & BIT7))