PIC16F628A Örnek RF Alıcı Verici Devresi C Dili ile

Projenin Kaynak isis simülasyon ve yazılım dosyaları pic16f628a-rf Emeği geçen Kişilere Teşekkürler
RF Alıcı Verici Devre Şeması

Alıcı.c
#include <16F628.h> #FUSES NOWDT,NOPUT,PROTECT,BROWNOUT,NOMCLR,NOLVP,INTRC_IO #use delay(clock=4000000) #use rs232(baud=300,parity=N,rcv = PIN_B1, XMIT = PIN_B2, bits=8, ERRORS,BRGH1OK ) #Byte PORTA = 5 #Byte PORTB = 6 #Bit C_ac = PortA.0 #Bit C_kapa = PortA.1 #Bit G_guvenlik = PortB.3 #Bit G_Acik = PortB.4 #Bit G_kapali = PortB.5 void ilk(); int8 x=0,y=0,Vtam=0,Basla=0; int8 dat[4]; #int_RDA void serial_isr() { if (Kbhit()) y=getc(); if ((y=='B')&&(!vtam)) Basla=1; if (Basla) {Dat[x]=y;x++; if (x > 2){ if (Dat[1] == 'C'){vtam=1;basla=0;x=0;}else {Vtam=0;basla=0;x=0;} } } } void main() { ilk(); while(1){ if (Vtam){ Disable_interrupts(GLOBAL); if (Dat[2]=='A') // Aç Komutu { if (G_kapali==0 && G_guvenlik==1) C_ac = 1; while (C_ac == 1){ if (G_acik==0) C_ac = 0; if (G_guvenlik==0) C_ac = 0; } } if (Dat[2]=='K') // Kapat Komutu { if (G_acik==0 && G_guvenlik==1) C_kapa = 1; while (C_kapa== 1){ if (G_kapali==0 || G_guvenlik==0) C_kapa = 0; } } vtam = 0; enable_interrupts(GLOBAL); } } } void ilk(){ Set_tris_B(0B00111010); Set_Tris_A(0); clear_interrupt(INT_RDA); clear_interrupt(INT_EXT); Disable_interrupts(GLOBAL); PortA = 0; PORTB = 0; port_b_pullups(TRUE); setup_timer_0(RTCC_INTERNAL); setup_timer_1(T1_DISABLED); setup_timer_2(T2_DISABLED,0,1); setup_comparator(NC_NC_NC_NC); setup_vref(FALSE); setup_uart(True); enable_interrupts(INT_RDA); enable_interrupts(GLOBAL); }
Verici.c
#include <16F628.h>
#FUSES NOWDT,NOPUT,NOPROTECT,BROWNOUT,NOMCLR,NOLVP,INTRC_IO
#use delay(clock=4000000)
#use rs232(baud=300,parity=N,rcv = PIN_B1, XMIT = PIN_B2, bits=8, ERRORS, BRGH1OK )
#Byte PORTA = 5
#Byte PORTB = 6
#Bit B_ac = PortB.4
#Bit B_kapat = PortB.5
void ilk();
void main()
{
ilk();
while(1){
if (B_ac==0) {
Putc('B');Putc('C');Putc('A');
Delay_ms(100);
Putc('B');Putc('C');Putc('A');
Delay_ms(100);
Putc('B');Putc('C');Putc('A');
Delay_ms(100);
}
if (B_kapat==0){
Putc('B');Putc('C');Putc('K');
Delay_ms(100);
Putc('B');Putc('C');Putc('K');
Delay_ms(100);
Putc('B');Putc('C');Putc('K');
Delay_ms(100);
}
}}
void ilk(){
Set_tris_B(0B00110010);
Set_Tris_A(0B00000000);
clear_interrupt(INT_RDA);
clear_interrupt(INT_EXT);
Disable_interrupts(GLOBAL);
PortA = 0;
PORTB = 0b11110010;
port_b_pullups(TRUE);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
setup_uart(True);
}
Yazar: gevv
Yazarımızın 320volt.com Blog üzerinde şu an okuduğunuz yazı dahil 1893 yazısı bulunmaktadır. Yazarımız hakkında bilgileri ve diğer yazılarını görmek için bakınız; gevv










Yazılar e-postanıza gönderilsin