MPLAB XC8 ile PIC Programlama – LED Blinking

main.c

/**************************************************************************
 MPLAB XC8 PIC Programlama - LED Blinking
 @author : Hakan Kaya
 @mail : mail@hakankaya.kim
 @site : www.hakankaya.kim/muh/muh
**************************************************************************/
#include "conf.h" // Kongifürasyon dosyası 

#define _XTAL_FREQ 20000000 // 20 mHz'lik kristal tanımlama

void GPIO_Init(); // Yaratılan fonksiyonların prototipleri

int main(){
 
 GPIO_Init(); // Fonksiyon çağırma

 while(1){ // Sonsuz döngü
 PORTB = 0xFF; // PORTB lojik-1
 __delay_ms(1000); // 1000 milisaniye bekleme
 PORTB = 0x00; // PORTB lojik-0
 __delay_ms(1000); // 1000 milisaniye bekleme
 }
 
 return 0;
}

void GPIO_Init(){
 TRISB = 0x00; // PORTB çıkış tanımlama
}

conf.h

#ifndef CONF_H
#define CONF_H

#ifdef __cplusplus
extern "C" {
#endif




#ifdef __cplusplus
}
#endif

#endif /* CONF_H */


// PIC16F877A Configuration Bit Settings

// 'C' source line config statements

#include <xc.h>

// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.

// CONFIG
#pragma config FOSC = HS // Oscillator Selection bits (HS oscillator)
#pragma config WDTE = ON // Watchdog Timer Enable bit (WDT enabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOREN = ON // Brown-out Reset Enable bit (BOR enabled)
#pragma config LVP = OFF // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming)
#pragma config CPD = OFF // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off)
#pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control)
#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off)
Hakan Kaya
Yarı zamanlı mühendis. Yarı zamanlı eğitmen. Biraz da film sever.
error: 5846 sayılı Fikir ve Sanat Eserleri Kanunu tarafında içeriklerin izinsiz kopyalanması, paylaşılması ve çoğaltılması yasaktır.