程序编译通过了,可是单步调试时在延时部分就不能运行,连续运行时总是报非法中断而且只点亮一个灯LED1,请问这是我延时函数写的不对吗?
#include
#include "derivative.h" /* include peripheral declarations */
#include "self.h"
/**************************************************************
Define the LED perameters
**************************************************************/
#define LED1 PTDD_PTDD4
#define LED1DIR PTDDD_PTDDD4
#define LED2 PTDD_PTDD5
#define LED2DIR PTDDD_PTDDD5
#define LED3 PTDD_PTDD6
#define LED3DIR PTDDD_PTDDD6
#define LED4 PTDD_PTDD7
#define LED4DIR PTDDD_PTDDD7
#define LED5 PTCD_PTCD4
#define LED5DIR PTCDD_PTCDD4
#define LED_ON 0
#define LED_OFF 1
#define DDIR_OUTPUT 1
#define DDIR_INPUT 0
#define LED_INIT_MACRO LED1 = LED_OFF; \
LED2 = LED_OFF; \
LED3 = LED_OFF; \
LED4 = LED_OFF; \
LED5 = LED_OFF; \
LED1DIR = DDIR_OUTPUT; \
LED2DIR = DDIR_OUTPUT; \
LED3DIR = DDIR_OUTPUT; \
LED4DIR = DDIR_OUTPUT; \
LED5DIR = DDIR_OUTPUT;
void WalkLED_1x(void);
void WalkLED_2x(void);
void Delay(UINT8 x);
/***********************************************
Main
***********************************************/
void main(void) {
LED_INIT_MACRO
for(;;) {
WalkLED_1x();
WalkLED_2x();
}
}
void WalkLED_1x(void){
LED1=LED_ON;
Delay(255);
LED1=LED_OFF;
LED2=LED_ON;
Delay(255);
LED2=LED_OFF;
LED3=LED_ON;
Delay(255);
LED3=LED_OFF;
LED4=LED_ON;
Delay(255);
LED4=LED_OFF;
}
void WalkLED_2x(void){
LED1=LED_ON;
Delay(100);
LED1=LED_OFF;
LED2=LED_ON;
Delay(100);
LED2=LED_OFF;
LED3=LED_ON;
Delay(100);
LED3=LED_OFF;
LED4=LED_ON;
Delay(100);
LED4=LED_OFF;
}
void Delay(UINT8 x){
UINT8 Tempvalue;
for(Tempvalue=0;Tempvalue<x;
for(Tempvalue=0;Tempvalue<10;Tempvalue++)
;
}
[此贴子已经被作者于2007-6-1 16:07:17编辑过]
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |