Picproje Elektronik Sitesi

DERLEYİCİLER => Microchip XC Serisi => Microchip XC8 => Konuyu başlatan: baran123 - 22 Mayıs 2015, 01:14:17

Başlık: Ynt: 16F1826 Konfigürasyon ayarları[Çözüldü]
Gönderen: baran123 - 22 Mayıs 2015, 01:14:17
XC8 de bu işlemci için konfigürasyon ayarlarını yapamadım.İşlemcinin kendi içindeki Internal 32MHz oscillator'Ü kullanmak istiyorum.Basit bir örnek örnek çalıştıramadım.

main.c

/*
* File:   main.c
*
* Author: Baran EKREM
*
* Created on 22 Mayıs 2015 Cuma, 00:51
*/
#include "main.h"

int main(void) {

    PORTB = 0xFF;
   
    while (1) {
       
    }
    return 0;
}


main.h

/*
* File:   main.h
*
* Author: Baran
*
* Created on 22 Mayıs 2015 Cuma, 00:58
*/
#ifndef MAIN_H
#define MAIN_H

#include <stdio.h>
#include <stdlib.h>
#include <xc.h>
#include <pic16f1826.h>

#pragma config FOSC = INTOSC    // Oscillator Selection (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 CPD = OFF        // Data Memory Code Protection (Data memory code protection is disabled)
#pragma config BOREN = OFF      // Brown-out Reset Enable (Brown-out Reset disabled)
#pragma config CLKOUTEN = OFF   // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
#pragma config IESO = OFF       // Internal/External Switchover (Internal/External Switchover mode is disabled)
#pragma config FCMEN = OFF      // Fail-Safe Clock Monitor Enable (Fail-Safe Clock Monitor is disabled)

// CONFIG2
#pragma config WRT = OFF        // Flash Memory Self-Write Protection (Write protection off)
#pragma config PLLEN = ON       // PLL Enable (4x PLL enabled)
#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 LVP = OFF        // Low-Voltage Programming Enable (High-voltage on MCLR/VPP must be used for programming)

#endif /* MAIN_H */


mesaj birleştirme:: 22 Mayıs 2015, 01:43:16

Tamam hallettim. :)

main.h da pragmalardan sonra frekansı unuttuk.
#define _XTAL_FREQ 32000000

main.c de OSCCON registerini şöyle ayarlıyoruz.(Internal kullanmak için)

OSCCON=0b01110010;


Datasheet de OSCCON kısmına bakabilirsiniz. http://ww1.microchip.com/downloads/en/DeviceDoc/41391D.pdf (http://ww1.microchip.com/downloads/en/DeviceDoc/41391D.pdf)