Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
3Activity
0 of .
Results for:
No results containing your search query
P. 1
Seri Portun Pic Pratik Kullanimi

Seri Portun Pic Pratik Kullanimi

Ratings: (0)|Views: 286|Likes:
Published by api-3810092

More info:

Published by: api-3810092 on Oct 17, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

03/18/2014

pdf

text

original

17.10.2008
Seri Portun PIC Mikro denetleyicilerle Pratik Kullan\u0131m\u0131

Hat\u0131rlayaca\u011f\u0131n\u0131z gibi daha \u00f6nceki makalede assambly dilini kullanarak PIC\u2019i
programlam\u0131\u015ft\u0131k. Bu yaz\u0131mda ise hem anlamas\u0131 hem de \u00fczerinde de\u011fi\u015fiklik yapmas\u0131 olduk\u00e7a
kolay olan C diliyle PIC programlayaca\u011f\u0131z. C bilmeyenler i\u00e7in yeri geldik\u00e7e bahsedece\u011fiz
de\u011fi\u015fiklikleri yaparak program\u0131 kendi ama\u00e7lar\u0131na g\u00f6re de\u011fi\u015ftirebilirler.

Bilgisayar yaz\u0131l\u0131m\u0131 olarak Visual Basic veya ba\u015fka bir programlama dili bilenler kendi
programlar\u0131n\u0131 yazabilirler. Bilgisayar programc\u0131l\u0131\u011f\u0131 ile aras\u0131 pek iyi olmayanlar
Hyperterminal\u2019i (Start>Programs>Accessories>Communications>Hyperterminal)
kullanabilirler. E\u011fer belirtti\u011fim yolda Hyperterminal\u2019e ula\u015fam\u0131yorsan\u0131z Program
Ekle/Kald\u0131r\u2019dan Hyperterminal\u2019i y\u00fcklemeniz gerekiyor.

Kulland\u0131\u011f\u0131m C derleyicisi CCS PIC C ad\u0131yla download edilebilir. Bu derleyici ile
ilgili sorunlar\u0131n\u0131z\u0131 bize bildirirseniz yard\u0131mc\u0131 olamaya \u00e7al\u0131\u015f\u0131r\u0131z.
Seri portla haberle\u015fmede kullan\u0131lacak PIC i\u00e7in C kodu a\u015fa\u011f\u0131da verilmi\u015ftir. Program
16F84 i\u00e7in yaz\u0131lm\u0131\u015f olmas\u0131na ra\u011fmen;
#include <16F84.h> sat\u0131r\u0131n\u0131 de\u011fi\u015ftirerek istedi\u011finiz bir PIC mikro denetleyiciyi
kullanabilirsiniz.

#use delay(clock=4000000), sat\u0131r\u0131 ile kulland\u0131\u011f\u0131n\u0131z kristal osilat\u00f6r\u00fcn h\u0131z\u0131n\u0131, #use
rs232(baud=9600, xmit=PIN_A1, rcv=PIN_A2) sat\u0131r\u0131 ile de seri haberle\u015fmede kullanaca\u011f\u0131n\u0131z
bacaklar\u0131 belirtiyorsunuz.

Hyperterminal\u2019in ileti\u015fim h\u0131z\u0131 9600 baud olarak ayarlanm\u0131\u015f olmal\u0131d\u0131r. \u0130\u00e7 USART\u2019\u0131
olan PIC\u2019ler i\u00e7in RX ve TX bacaklar\u0131n\u0131 kullanman\u0131z daha verimli olacakt\u0131r (\u00f6rne\u011fin PIC
16F877 i\u00e7in RC7 RX ve RC6 TX bacaklar\u0131 kullan\u0131lmal\u0131d\u0131r).

#byte port_b = 6 sat\u0131r\u0131 PORTB\u2019nin Register\u2019lar (Register Map) aras\u0131ndaki yerini
g\u00f6sterir. PORTA i\u00e7in bu sat\u0131r #byte port_a = 5 \u015feklinde de\u011fi\u015ftirilmelidir. port_A veya port_B
isimleri keyfidir siz bu isimleri programda da de\u011fi\u015ftirmek \u015fart\u0131yla istedi\u011finiz gibi
de\u011fi\u015ftirebilirsiniz. set_tris_b( 0x00 ); sat\u0131r\u0131 PORTB\u2019nin \u00e7\u0131k\u0131\u015f olaca\u011f\u0131n\u0131 belirtiyor.

Bir portu giri\u015f yapmak i\u00e7in bu sat\u0131r set_tris_b( 0xFF ); \u015feklinde de\u011fi\u015ftirilmelidir.
While (TRUE) sat\u0131r\u0131 sonsuz bir d\u00f6ng\u00fc yaratmak i\u00e7in kullan\u0131lm\u0131\u015ft\u0131r.

Programda \u00f6nce data ad\u0131nda bir de\u011fi\u015fken tan\u0131mlan\u0131yor ve Hyperterminalden okunan
tu\u015f bu de\u011fi\u015fkene atan\u0131yor. Daha sonra bo\u015f de\u011fi\u015fken PORTB\u2019ye g\u00f6nderiliyor. data de\u011fi\u015fkenini
kullanmay\u0131p port_b = getch(); sat\u0131r\u0131 ile de ayn\u0131 i\u015f yap\u0131lm\u0131\u015f olur. delay_ms(1000); sat\u0131r\u0131 1000
mili saniye yani 1 saniyelik gecikme sa\u011flamak i\u00e7in kullan\u0131lm\u0131\u015ft\u0131r.

B\u00f6ylece bas\u0131lan tu\u015fun ascii de\u011feri en az 1 saniye PORTB\u2019deki LED\u2019lerde g\u00f6r\u00fcl\u00fcr.
Herhangi bir tu\u015fun ASCII kar\u015f\u0131l\u0131\u011f\u0131n\u0131 \u00f6\u011frenmek i\u00e7in a\u015fa\u011f\u0131da verdi\u011fimiz tabloyu
kullanabilirsiniz.

PIC mikro denetleyicinin bacaklar\u0131n\u0131 seri portun Rx ve Tx giri\u015flerine do\u011frudan girmek
yerine arada MAX232 entegresini kullanmak verilerin hatas\u0131z iletimi a\u00e7\u0131s\u0131ndan gereklidir.
MAX232 entegresi -12, +12 V seviyesindeki seri port sinyallerini TTL (+5, 0 V) seviyesine
veya TTL seviyesini -12 V, +12 V sinyallerine \u00e7evirir. Resimde PA1 ve PA2 PIC16F84\u2019\u00fcn
PORTA 1 ve 2 bacaklar\u0131d\u0131r.

1
17.10.2008
PC seiportu ile PIC\u2019in MAX232 ile birbirine ba\u011flanmas\u0131
2
17.10.2008
Bilgisayardan PIC\u2019e Seri Portla Bilgi G\u00f6ndermek
Bilgisayardan PIC\u2019e Seri Portla Bilgi G\u00f6ndermek i\u00e7in gerekli devre
//klavyeden girilen tu\u015f de\u011feri portb ye ba\u011fl\u0131 ledlerde g\u00f6r\u00fcl\u00fcr

#include <16F84.h>
#fuses XT,NOWDT,NOPROTECT
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_A1, rcv=PIN_A2)

#byte port_b = 6
//portb nin ramdeki yeri

main() {
int data;
set_tris_b( 0x00 ); //portb \u00e7\u0131k\u0131\u015f
printf("calisiyor\u2026\n\r");
while (TRUE)

{
data = getch();
port_b = data;
//g\u00f6nderilen say\u0131y\u0131 portb de g\u00f6ster
delay_ms(1000);
3

Activity (3)

You've already reviewed this. Edit your review.
1 thousand reads
1 hundred reads
osmanatam liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->