XC8例子:MPLAB X 1.60, xc8, PIC16f690

来源:互联网 发布:a5淘宝客助手v1.8 编辑:程序博客网 时间:2024/05/16 18:14
#include  <xc.h> 

 
// CONFIG 
#pragma config FOSC = INTRCCLK  // Oscillator Selection bits (INTOSC oscillator: CLKOUT function on RA4/OSC2/CLKOUT pin, I/O function on RA5/OSC1/CLKIN) 
#pragma config WDTE = OFF       // Watchdog Timer Enable bit (WDT disabled and can be enabled by SWDTEN bit of the WDTCON register) 
#pragma config PWRTE = OFF      // Power-up Timer Enable bit (PWRT disabled) 
#pragma config MCLRE = ON       // MCLR Pin Function Select bit (MCLR pin function is MCLR) 
#pragma config CP = OFF         // Code Protection bit (Program memory code protection is disabled) 
#pragma config CPD = OFF        // Data Code Protection bit (Data memory code protection is disabled) 
#pragma config BOREN = ON       // Brown-out Reset Selection bits (BOR enabled) 
#pragma config IESO = OFF       // Internal External Switchover bit (Internal External Switchover mode is disabled) 
#pragma config FCMEN = ON       // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is enabled) 
 
#define _XTAL_FREQ 8000000  //required for _delay() function 
   
 
void init(void){ 
    TRISA
=0b00000000;   //PORTA is output 
    PORTA
=0b00000000;   //PORTA initially off 
 
   
 //GIE=1;       //enable global interrupts 
} 
   
 
//system test function 
void sys_test(void){ 
   
 unsigned char loopctr=0;    //loop counter 
   
 for(loopctr=0; loopctr <=3; loopctr++){ 
        PORTA
=0b00001111;   //turn on LEDs 
        __delay_ms
(500); 
        PORTA
=0b00000000;   //turn off LEDs 
        __delay_ms
(500); 
   
 } 
} 
1 0
原创粉丝点击