arkadaşlar elimde pic16f1516 olduğu için xc8i bunun üzerinde öğrenmeye çalışıyorum kodda derleme hatası almıyorum ama proteusta çalıştıramadım kodum;
#include <xc.h>
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
// CONFIG1
#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 = ON // 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)
#pragma config IESO = ON // Internal/External Switchover (Internal/External Switchover mode is enabled)
#pragma config FCMEN = ON // Fail-Safe Clock Monitor Enable (Fail-Safe Clock Monitor is enabled)
// CONFIG2
#pragma config WRT = OFF // Flash Memory Self-Write Protection (Write protection off)
#pragma config VCAPEN = OFF // Voltage Regulator Capacitor Enable bit (VCAP pin function disabled)
#pragma config STVREN = ON // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will cause a Reset)
#pragma config BORV = LO // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.)
#pragma config LPBOR = OFF // Low-Power Brown Out Reset (Low-Power BOR is disabled)
#pragma config LVP = OFF // Low-Voltage Programming Enable (High-voltage on MCLR/VPP must be used for programming)
#define _XTAL_FREQ 8000000L
#include <stdio.h>
#include <stdlib.h>
#include "hadii.h"
void main(void)
{
PORTBbits.RB0=1;
OSCCON=0x70;
while(1)
{
LATBbits.LATB0=~LATBbits.LATB0;
for(int count=0;count<20;count++)
__delay_ms(50);
}
}
yardımcı olursanız sevinirim
portb nin gerekli pinini (trisb1) once cikis yapmalisin.
#include <stdio.h>
#include <stdlib.h>
#include "hadii.h"
void main(void)
{
PORTBbits.RB0=1;
TRISBbits.RB0=0; // ilgili pin çıkış yapılıyor
OSCCON=0x70; //8MHz int clock
while(1)
{
LATBbits.LATB0=~LATBbits.LATB0;
//for(int count=0;count<20;count++)
// __delay_ms(50);
__delay_ms(1000); // bu şekilde de yapılabilir.
}
}
çok teşekkür ederim daha başınızı çok ağrıtacam sağolun
LATBbits.LATB0 = !LATBbits.LATB0; birde boyle bakarmisin.
hocam çalıştırdım TRISB0=0;
bu kısmı ekleyip PORTBbits.RB0=1;
bunu çıkarınca çalıştı teşekkürler
portlarin tris yazmaclari portlarin giris veya cikis pozisyonlarini ayarlar.
portb nin trisb
porta nın trisa
portc nin trisc
eger portunun ilgili pini (seninki rb0) cikis olacaksa ki senin programinda cikis. portb nin trisb0 ini cikis yapman gerekiyor eger bunu PORTBbits.RB0=1 komutundan once belitmesen cikis alamzsin.
eger portun giris olsun istiyorsan (mesela bir buton bagladigini dusun ve butonu okumak istiyorsun) bu sefer TRISB0=1; demelisin
aklinda kalsin diye bir benzetme yapalim 1 = i ///input 0 = o /// output