#include <pic18.h>
#include "a2demo.h"
#include "iodemo.h"
#include "timer0.h"
#include <stdio.h>
void delay(unsigned int t); //延时函数声明
//#pragma config CONFIG1L = 0xA0
__CONFIG(1, WDTEN_OFF & STVREN_ON & XINST_OFF);
//#pragma config CONFIG1H = 0xF4
__CONFIG(2, CP0_OFF);
//#pragma config CONFIG2L = 0xC4
__CONFIG(3, FOSC_HS & FOSC2_ON & FCMEN_ON & IESO_ON);
//#pragma config CONFIG2H = 0xFF
__CONFIG(4, WDTPS_32768);
//#pragma config CONFIG3H = 0xF1
__CONFIG(5, CCP2MX_DEFAULT);
/*
* Interrupt demo for PIC; wait for button press on RB0/INT,
* turn on a relay on another port bit for a period of time.
* For simplicity here, literal constants are used, usually these
* should be calculated with compile-time arithmetic.
*/
static unsigned int relay_timer; // timer value for relay driver
void main(void)
{
io_init();
while(1)
{
LATB = 0x55;
delay(5000);
LATB = 0xaa;
delay(5000);
}
}
void delay(unsigned int t) //延时函数
{
unsigned int x,y;
for(x=t;x>0;x--)
{
for(y=100;y>0;y--);
}
}
完整工程文件是不可能了,给你一个跑马灯范例跑跑还是没什么问题的
|