| 
 
| 单个端口使LED闪烁,LED_G = ~LED_G 877A可以,1823却不行,为啥? /***********************************************************
 项目:练习PIC内部时钟使用
 功能:练习PIC内部时钟使用
 设计:robin_chen559
 日期:2013.11.21
 备注:
 ***********************************************************/
 #include<pic12lf1822.h>
 
 #define LED_G RA0
 
 //子程序声明
 void Delay_MS(unsigned int MS);        //延时子程序
 void LED_Flash(void);                  //LED闪烁子程序
 
 //子程序
 
 void Delay_MS(unsigned int MS)         //延时子程序
 {
 unsigned int i,j;
 for(i=0;i<MS;i++)
 for(j=0;j<90;j++);
 }
 
 void LED_Flash(void)
 {
 LED_G = 0;                       //LED_G闪烁
 Delay_MS(200);
 LED_G = 1;                       //LED_G闪烁
 Delay_MS(200);
 
 /************
 LED_G = ~LED_G;                       //LED_G闪烁
 Delay_MS(200);
 ************/
 
 }
 
 void main(void)
 {
 OSCCON = 0b01101010;                   //内部时钟4M
 TRISA0 = 0x00;                         //A0口输出
 LED_G = 0;
 while(1)
 {
 LED_Flash();
 }
 }
 
 877A的好使,没这个问题。
 /******************************************************
 1.项目:877A LED闪烁
 2.功能:877A使LED闪烁
 3.设计:robin_chen559
 4.日期:2013.12.28
 
 ******************************************************/
 #include<pic.h>
 
 #define uchar unsigned char
 #define uint unsigned int
 
 #define LED_R RB0           //定义LED端口
 
 //子程序声明
 void Delay_MS(uint MS);
 void LED_Flash(void);
 
 //子程序
 
 void Delay_MS(uint MS)     //延时子程序
 {
 uint i,j;
 for(i=0;i<MS;i++)
 for(j=0;j<22;j++);
 }
 
 void LED_Flash(void)
 {
 LED_R = ~LED_R;
 Delay_MS(500);
 }
 
 void main(void)
 {
 TRISB = 0x00;          //设置RB口为输出
 LED_R = 0;
 while(1)
 {
 LED_Flash();
 }
 }
 
 1.1823源文件包,mplab8.70 proteus7.10
 http://pan.baidu.com/s/1o66UF5w
 2.877A源文件包
 http://pan.baidu.com/s/1i3HUpgx
 | 
 |