#include <xc.h>
// #pragma config s tatements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
// CONFIG1
#pragma config FOSC = INTOSC // (INTOSC oscillator; I/O function on CLKIN pin)
#pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable (PWRT disabled)
#pragma config MCLRE = OFF // MCLR Pin Function Select (MCLR/VPP pin function is digital input)
#pragma config CP = OFF // Flash Program Memory Code Protection (Program memory code protection is disabled)
#pragma config BOREN = ON // Brown-out Reset Enable (Brown-out Reset enabled)
#pragma config CLKOUTEN = OFF // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
// CONFIG2
#pragma config WRT = OFF // Flash Memory Self-Write Protection (Write protection off)
#pragma config PLLEN = OFF // PLL Enable (4x PLL disabled)
#pragma config STVREN = OFF // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will not cause a Reset)
#pragma config BORV = LO // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.)
#pragma config LPBOREN = OFF // Low Power Brown-out Reset enable bit (LPBOR is disabled)
#pragma config LVP = ON // Low-Voltage Programming Enable (Low-voltage programming enabled)
#define uint unsigned int
#define uchar unsigned char
#define IN_HI RA2
#define IN_LO RA0
void jiance();
void Delay_MS(uint n);
void SysIinit();
void delay_us(uint n);
void Delay_MS(uint n)
{
uint j;
char k;
for(j=0;j<n;j++)
for(k=246;k>0;k--) NOP();
}
void delay_us(uint n)
{
uint j;
for(j=0;j<n;j++)
NOP();
}
// PIC12F1572 Configuration Bit Settings
// 'C' source line config statements
#include <xc.h>
// #pragma config s tatements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
// CONFIG1
#pragma config FOSC = INTOSC // (INTOSC oscillator; I/O function on CLKIN pin)
#pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable (PWRT disabled)
#pragma config MCLRE = OFF // MCLR Pin Function Select (MCLR/VPP pin function is digital input)
#pragma config CP = OFF // Flash Program Memory Code Protection (Program memory code protection is disabled)
#pragma config BOREN = ON // Brown-out Reset Enable (Brown-out Reset enabled)
#pragma config CLKOUTEN = OFF // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
// CONFIG2
#pragma config WRT = OFF // Flash Memory Self-Write Protection (Write protection off)
#pragma config PLLEN = OFF // PLL Enable (4x PLL disabled)
#pragma config STVREN = OFF // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will not cause a Reset)
#pragma config BORV = LO // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.)
#pragma config LPBOREN = OFF // Low Power Brown-out Reset enable bit (LPBOR is disabled)
#pragma config LVP = ON // Low-Voltage Programming Enable (Low-voltage programming enabled)
#define uint unsigned int
#define uchar unsigned char
#define IN_HI RA2
#define IN_LO RA0
void jiance();
void Delay_MS(uint n);
void SysIinit();
void delay_us(uint n);
void Delay_MS(uint n)
{
uint j;
char k;
for(j=0;j<n;j++)
for(k=246;k>0;k--) NOP();
}
void delay_us(uint n)
{
uint j;
for(j=0;j<n;j++)
NOP();
}
void SysIinit()
{
PORTA=0x00;
LATA=0x00;
TRISA=0x00;
ANSELA=0x00;
WPUA = 0x00;
// OSCCON=0x7a;//16MHz
// OSCCON=0xf2;//32MHz
// OSCCON=0x72;//8MHz
OSCCON=0x6a;//4MHz
}
void pulse()
{
IN_HI=0;
NOP();NOP();
// Delay_MS(5);
IN_LO=1;
NOP();NOP();
// Delay_MS(90);
IN_LO=0;
NOP();NOP();
// Delay_MS(5);
IN_HI=1;
// Delay_MS(25);
NOP();NOP();
}
void main()
{
SysIinit();
while(1)
{
pulse();
}
}
一周热门 更多>