比神乐 发表于 2024-5-15 10:32

ICCVR建立工程运行有问题

代码
//ICC-AVR application builder : 2012/2/13 20:52:33
/*******************************************************************************
* 版权:   涛哥
*
* 单片机:   ATMAGE64A AU 1036
* 晶振:   外部8MHz
* 编译器:   ICC 7.22
*
* 文件名:   main.c
* 版本:   1.0
* 完成日期:
* 功能描述: 在8M晶振下,实现6路LED流水灯操作
*******************************************************************************/
#include <iom128v.h>
#include <macros.h>

#define LED PORTF
#define BEEL_ONPORTB |= BIT(0);
#define BEEL_OFF PORTB &= ~BIT(0);

/*******************************************************************************
* 函数名称: delay_us()
* 入口参数: microsecond : 输入延时微秒的时间
* 出口参数:
* 功能描述: 微秒的延时                    
*******************************************************************************/
void delay_us(unsigned int microsecond)
{      
    do
        {
      microsecond--;
        }         
    while (microsecond>1);
}
/*******************************************************************************
* 函数名称: delay_ms()
* 入口参数: millisecond : 输入延时毫秒的时间
* 出口参数:
* 功能描述: 毫秒的延时       
*******************************************************************************/
void delay_ms(unsigned int millisecond)
{      
    while (millisecond--)
        {
      delay_us(999);
        }
}
void port_init(void)
{
PORTA = 0x07;   
DDRA= 0x07;
PORTB = 0x01;
DDRB= 0x01;
PORTC = 0x00; //m103 output only
DDRC= 0x00;
PORTD = 0xFF;
DDRD= 0xFF;
PORTE = 0x00;
DDRE= 0x00;
PORTF = 0xFF;   //输入输出模式的设置!    1:为输入模式2:为输出模式!
DDRF= 0xFF;   //LED口 PF2~PF7
PORTG = 0x00;
DDRG= 0x00;
}

//call this routine to initialize all peripherals
void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
XDIV= 0x00; //xtal divider
XMCRA = 0x00; //external memory
port_init();


MCUCR = 0x00;
EICRA = 0x00; //extended ext ints
EICRB = 0x00; //extended ext ints
EIMSK = 0x00;
TIMSK = 0x00; //timer interrupt sources
ETIMSK = 0x00; //extended timer interrupt sources
//SEI(); //re-enable interrupts
//all peripherals are now initialized
}

void main(void)
{
        unsigned char l;
        unsigned int k;
            init_devices();
        BEEL_ON;
        delay_ms(100);
        BEEL_OFF;
        PORTF=0XFF;
        PORTD=0X00;
        PORTA=0X00;
    while(1)
    {
          PORTF= 0X00;
                delay_ms(100);
                PORTF = 0XFF;
                delay_ms(100);
               
    }
}

原理图

可是运行只有两个灯闪。请问高手,如何解决?谢谢!
页: [1]
查看完整版本: ICCVR建立工程运行有问题