|
#include<iom16v.h>
#define BAUD 9600 //波特率采用9600
#define CRYSTAL 8000000 //系统时钟8MHz
#define BAUD_SETTING (unsigned char)((unsigned long)CRYSTAL/(16*(unsigned long)BAUD)-1) // 设置波特率
#define BAUD_H (unsigned char)(BAUD_SETTING>>8)
#define BAUD_L (unsigned char)(BAUD_SETTING)
#define _nop() #asm("nop")
//PORT D///////////
#define EN_485 4
#define RUN 5
void delay(char k) //延时ms
{
unsigned char j;
for(;k>0;k--)
for(j=220;j>0;j--)
_nop();
}
//===========================
//main主程序
//===========================
void main()
{
unsigned char i,j;
DDRD |= (1<<RUN);
SREG =0x00;
TIMSK |= (1<<TOIE1);
TCCR1B = 0x00;
TCNT1 = 0x00;
TCCR1B |= (1<<CS11);
UCSRB |= (1<<RXCIE);
USART_Init();
SREG = 0x80;
PORTD |= (1<<RUN);
delay(200);
PORTD &= ~(1<<RUN);
while(1)
{
}
}
for语句只有一次循环,也跳不出来,所以一到延时地方就停了。谁知道怎么回事啊
|
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|