|
发表于 2010-8-31 09:16:20
|
显示全部楼层
"#include "pic.h"
__CONFIG(0x0044);
//高门槛电压,取消MCRL,将GP3配置为数字IO,程序保护,数据区保护,看门狗停止,BOD使能,上电延时定时器启动,内部RC晶体
"
both are stupid ways of coding the chip. You should always stay with the right approach for header files, like the following:
==============
#include <htc.h>
__CONFIG(MCLRDIS & BORDIS & WDTDIS & PWRTEN & INTIO); //add others as you wish
==============
"//延时子程序
void delay(unsigned int t)"
the parameter to delay is an unsigned int. so make sure that when you call this routine, it doesn't exceed the maximum value of unsigned int.
" TRISIO&=~0x07;//GPIO0~GPIO3为输出 "
really? you must have not read the datasheet.
" OPTION&=~0x80;"
why do you need this?
" WPU=0b0111;//GPIO2为弱上拉,GPIO0,GPIO1输出高电平"
you are enabling wpu on an output pin? have you lost your mind?
" CMCON=0x07;//比较器关闭(功耗最低)"
good.
" ANSEL&=0xf0;//GPIO设置为数字IO"
doesn't make sense.
" ei();//开中断"
why?
" CLRWDT();"
totally moronic.
" NOP();
NOP();"
totally moronic.
" NOP();
NOP();
delay(40000);"
totally moronic.
you need to understand what you are doing. to do that, you need to read the datasheet, many times over.
right now, you have no clue what you are trying to do. |
|