|
第一次用ST7LITEU05点亮LED,请大哥指点
[复制链接]
A5口接LED,计划是低电平亮,可是示波器看A5脚电平长期高电位不变,下面是源代码,COSMIC C和STVD7平台,各位大哥帮忙看看哪里不对,谢谢啦。。。
#include <io7flitus.h> #include <stdlib.h>
/*----Define Bit Operation Macro---*/ #define SetBit(VAR,BIT_NUM) ( (VAR) |= (1<<(BIT_NUM)) ) #define ClrBit(VAR,BIT_NUM) ( (VAR) &= ((1<<(BIT_NUM))^0xFF) ) #define ValBit(VAR,BIT_NUM) ( (VAR) & (1<<(BIT_NUM)) ) #define BitIsClear(VAR,BIT_NUM) ( 0 == ValBit(VAR,BIT_NUM) ) #define BitIsSet(VAR,BIT_NUM) ( !BitIsClear(VAR,BIT_NUM) )
#define EnableInterrupts {_asm ("RIM");} #define DisableInterrupts {_asm ("SIM");} #define Nop {_asm ("nop");} #define WaitforInterrupt {_asm ("wfi");}
#define LED_ON ClrBit(PADR,5) #define LED_OFF SetBit(PADR,5)
/*---Define functions---*/ void gInitialize(void); void gDelayms(unsigned char a);
/*---Main routine---*/ void main (void) { gInitialize(); while (1) { LED_ON; gDelayms(255); LED_OFF; gDelayms(255); } }
/*----Function: gDelayms()---*/ void gDelayms(unsigned char a) { unsigned short k; for(k=192*a;k>0;k--); }
/*---Function: gInitialize()---*/ void gInitialize(void) { // Set internal RC clock RCCR = RCCRH0; SICSR = RCCRL0; AVDTHCR = 0x23; //set the internal RC oscillator Prescaler to 4MHz. // Set input/output pins: PADDR = 0x3F; PAOR = 0x3F; PADR = 0x00; //Clear all output, }
|
|