yasin50
Üye
- Katılım
- 22 Eyl 2022
- Mesajlar
- 1
- Puanları
- 1
- Yaş
- 25
Düşündüğüm bir projeyi yapmak için, deneme amaçlı PIC vasıtasıyla hc-05 i terminalle haberleştirmek istiyorum. Bunun için terminalden 1 verisi geldiğin LED yanacak 0 verisi geldiğinde led sönecek. Fakat yaptığım pojede 1 verisi gönderdiğimde led yanmıyor. Kodlamasını MPLAB ortamı üzerinden yapmıştım. Ayrıca hc-05 ve PIC de herhangi bir sorun yok çünkü arduino ile bu projeyi gerçekleştirmiştim fakat PIC ile yapınca olmuyor
Eğer bu projeyi önceden gerçekleştirmiş arkadaşlar ya da tecrübeli kişiler var ise yardım edebilir mi ?
Kod:
// CONFIG
#pragma config FOSC = XT // Oscillator Selection bits (HS oscillator)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOREN = OFF // Brown-out Reset Enable bit (BOR enabled)
#pragma config LVP = OFF // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3/PGM pin has PGM function; low-voltage programming enabled)
#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)
#include <stdint.h>
//#include <proc/pic16f877a.h>
//#include <proc/pic16f877a.h>
#include <xc.h>
//#include <stdio.h>
//#include <string.h>
//#include <htc.h>
#define _XTAL_FREQ 4000000
uint8_t volatile data;
//__CONFIG(0x3F32);
//USART ASYNCHRONOUS RECEIVER
void __interrupt() isr()
{
if(RCIF == 1)
{
data = RCREG;
RCIF = 0;
}
}
void main(void)
{
TRISB0 = 0;
PEIE = 1;
RCIE = 1;
RB0=RB1=RB2=0;
TRISC7=1;
TRISC6=1; //
TRISB = 0;
PORTB=0X00;
TXSTA=0X24;
RCSTA=0X90;
SPBRG=25;
GIE = 1;
while(1)
{
if(data == '1')
{
RB0 = 1;
}
else if(data == '0')
{
RB0 = 0;
}
}
return;
}
Eğer bu projeyi önceden gerçekleştirmiş arkadaşlar ya da tecrübeli kişiler var ise yardım edebilir mi ?
Kod:
// CONFIG
#pragma config FOSC = XT // Oscillator Selection bits (HS oscillator)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOREN = OFF // Brown-out Reset Enable bit (BOR enabled)
#pragma config LVP = OFF // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3/PGM pin has PGM function; low-voltage programming enabled)
#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)
#include <stdint.h>
//#include <proc/pic16f877a.h>
//#include <proc/pic16f877a.h>
#include <xc.h>
//#include <stdio.h>
//#include <string.h>
//#include <htc.h>
#define _XTAL_FREQ 4000000
uint8_t volatile data;
//__CONFIG(0x3F32);
//USART ASYNCHRONOUS RECEIVER
void __interrupt() isr()
{
if(RCIF == 1)
{
data = RCREG;
RCIF = 0;
}
}
void main(void)
{
TRISB0 = 0;
PEIE = 1;
RCIE = 1;
RB0=RB1=RB2=0;
TRISC7=1;
TRISC6=1; //
TRISB = 0;
PORTB=0X00;
TXSTA=0X24;
RCSTA=0X90;
SPBRG=25;
GIE = 1;
while(1)
{
if(data == '1')
{
RB0 = 1;
}
else if(data == '0')
{
RB0 = 0;
}
}
return;
}