[AVR单片机] ICCVR建立工程运行有问题

[复制链接]
 楼主| 比神乐 发表于 2024-5-15 10:32 | 显示全部楼层 |阅读模式
代码
  1. //ICC-AVR application builder : 2012/2/13 20:52:33
  2. /*******************************************************************************
  3. * 版权:     涛哥
  4. *
  5. * 单片机:   ATMAGE64A AU 1036
  6. * 晶振:     外部8MHz
  7. * 编译器:   ICC 7.22
  8. *
  9. * 文件名:   main.c
  10. * 版本:     1.0
  11. * 完成日期:
  12. * 功能描述: 在8M晶振下,实现6路LED流水灯操作
  13. *******************************************************************************/
  14. #include <iom128v.h>
  15. #include <macros.h>

  16. #define LED PORTF
  17. #define BEEL_ON  PORTB |= BIT(0);
  18. #define BEEL_OFF PORTB &= ~BIT(0);

  19. /*******************************************************************************
  20. * 函数名称: delay_us()
  21. * 入口参数: microsecond : 输入延时微秒的时间
  22. * 出口参数:
  23. * 功能描述: 微秒的延时                    
  24. *******************************************************************************/
  25. void delay_us(unsigned int microsecond)
  26. {      
  27.     do
  28.         {
  29.         microsecond--;
  30.         }         
  31.     while (microsecond>1);
  32. }
  33. /*******************************************************************************
  34. * 函数名称: delay_ms()
  35. * 入口参数: millisecond : 输入延时毫秒的时间
  36. * 出口参数:
  37. * 功能描述: 毫秒的延时         
  38. *******************************************************************************/
  39. void delay_ms(unsigned int millisecond)
  40. {      
  41.     while (millisecond--)
  42.         {
  43.         delay_us(999);
  44.         }  
  45. }
  46. void port_init(void)
  47. {
  48. PORTA = 0x07;     
  49. DDRA  = 0x07;
  50. PORTB = 0x01;
  51. DDRB  = 0x01;
  52. PORTC = 0x00; //m103 output only
  53. DDRC  = 0x00;
  54. PORTD = 0xFF;
  55. DDRD  = 0xFF;
  56. PORTE = 0x00;
  57. DDRE  = 0x00;
  58. PORTF = 0xFF;   //输入输出模式的设置!    1:为输入模式  2:为输出模式!
  59. DDRF  = 0xFF;   //LED口 PF2~PF7  
  60. PORTG = 0x00;
  61. DDRG  = 0x00;
  62. }

  63. //call this routine to initialize all peripherals
  64. void init_devices(void)
  65. {
  66. //stop errant interrupts until set up
  67. CLI(); //disable all interrupts
  68. XDIV  = 0x00; //xtal divider
  69. XMCRA = 0x00; //external memory
  70. port_init();


  71. MCUCR = 0x00;
  72. EICRA = 0x00; //extended ext ints
  73. EICRB = 0x00; //extended ext ints
  74. EIMSK = 0x00;
  75. TIMSK = 0x00; //timer interrupt sources
  76. ETIMSK = 0x00; //extended timer interrupt sources
  77. //SEI(); //re-enable interrupts
  78. //all peripherals are now initialized
  79. }

  80. void main(void)
  81. {
  82.         unsigned char l;
  83.         unsigned int k;
  84.             init_devices();
  85.         BEEL_ON;
  86.         delay_ms(100);
  87.         BEEL_OFF;
  88.         PORTF=0XFF;
  89.         PORTD=0X00;
  90.         PORTA=0X00;
  91.     while(1)
  92.     {
  93.             PORTF= 0X00;
  94.                 delay_ms(100);
  95.                 PORTF = 0XFF;
  96.                 delay_ms(100);
  97.                
  98.     }
  99. }

原理图

可是运行只有两个灯闪。请问高手,如何解决?谢谢!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
您需要登录后才可以回帖 登录 | 注册

本版积分规则

470

主题

3535

帖子

7

粉丝
快速回复 在线客服 返回列表 返回顶部