历史上的今天
今天是:2025年05月25日(星期日)
2021年05月25日 | MSP430G2553定时器中断实验
2021-05-25 来源:eefocus
///////////////////////////////////////////////////////////////////
// msp430G2553的定时器中断控制LED每秒钟进行亮熄变化
///////////////////////////////////////////////////////////////////
#include
void led_init();
void timer_init();
void delay(int);
//----------------------------------
void led_init()
{
P1DIR|=(1<<6); //P1.6为LED
}
//--------------------------
void timer_init()
{
TACCR0 =2500; //计到2500,约20ms
TACTL = TASSEL_2+ID_3+MC_1+TACLR; //设置TIMERA的时钟源为SMCLK(1M),8分频后(125K),计数模式为up,到CCR0再自动从0开始计数
TACCTL0 |= CCIE; // CCR0 interrupt enabled
}
//--------定时器中断函数------------
#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer_A(void)
{
//TACCTL0&=~ CCIE; //关中断
static int cc=0;
cc+=1;
if(cc==50) //1s=1000ms=20*50 定时
{
P1OUT^=(1<<6); //P1.6 LED取反
cc=0;
}
}
//--------延时函数 -------
void delay(int n)
{
unsigned char temp = 0;
unsigned int i=0;
for(i=0;i
{
for(temp=0;temp<33;temp++);
}
}
//************主函数***************************
void main()
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
BCSCTL1 = CALBC1_1MHZ;
DCOCTL = CALDCO_1MHZ;
led_init();
timer_init();
_BIS_SR(GIE); //开总中断
for(;;)
{
;
}
}
史海拾趣
|
目录: 第一章 电子继电器 第二章 非门 第三章 与门和或门 第四章 其他类型的门电路 第五章 实用电路 详细信息: 陈永有 王永江著 人民邮电出版社 1978-12… 查看全部问答> |
|
我用的是MPC8280。上面跑vxworks5.5. 采用bootRom + vxworks image的方式。 一种方法是bootrom起来后从网络加载vxworks映像的方式进行调试。调试串口和已经打通。 但是,在boot的过程中,选择从FCC1下载vxworks映像 ...… 查看全部问答> |
|
19. 设备管理函数原型?编写一个设备管理(驱动)的例子? 20. 设备管理作业:举出5个驱动程序的常用接口函数 21. exe和elf文件加载及加载的过程? 22.  ...… 查看全部问答> |
|
Initiating image download in 5 seconds. Ethernet Boot Loader Configuration: 0) IP address: 0.0.0.0 1) Subnet mask: 255.255.255.0 2) DHCP: Disabled 3) Boot delay: 5 seconds 4) Reset to factory default configuration 5) Start ...… 查看全部问答> |
|
wince 中出现的问题cannot launch the remote executable 点击但步执行,出现下面对话框 Cannot launch the remote executable Error: File not found Win32 error code : 2 点击该对话框上的按钮:确定 则出现下面提示: Please check the remote exectuable path and file neme from your projec ...… 查看全部问答> |




