0
#device ADC=10
19.
fuses HSPLL, NOWDT,NOPROTECT, NOLVP,NODEBUG, USBDIV,PLL2,CPUDIV1,VREGEN, NOBROWNOUT // 8MHZ
20.
use delay(clock=48000000)
21.
define USB_HID_DEVICE TRUE
22.
define USB_EP1_TX_ENABLE USB_ENABLE_INTERRUPT //Uçnokta1'de Kesme transferi aktif
23.
define USB_EP1_RX_ENABLE USB_ENABLE_INTERRUPT
24.
define USB_EP1_TX_SIZE 64 //Uçnokta1 için maksimum alınacak ve gonderilecek
25.
define USB_EP1_RX_SIZE 64
26.
include <pic18_usb.h>
27.
include <USB_Driver.h> //USB konfigurasyon bilgileri bu dosyadadır.
28.
include <usb.c>
29.
include <lcd_driver.c>
30.
include <One_Wire.c>
31.
include <DS1820.c>
32.
use fast_io(a)
33.
use fast_io(b)
34.
use fast_io(c)
35.
use fast_io(d)
36.
define UcNokta1 1
unsigned int16 Term;
unsigned int8 paket[64];
unsigned int8 Tam, Onda;
float Sicaklik;
void main()
{
setup_timer_3(T3_DISABLED | T3_DIV_BY_1);
set_tris_a(0x00);
set_tris_b(0x00);
set_tris_c(0x00);
set_tris_d(0x00);
output_a(0x00);
output_b(0x00);
output_c(0x00);
output_d(0x00);
lcd_init();
output_high(pin_b7);
delay_ms(100);
output_low(pin_b7);
printf(lcd_putc,"f");
printf(lcd_putc,"USB Baglantisi");
lcd_gotoxy(1,2);
printf(lcd_putc,"Bekleniyor");
delay_ms(100);
usb_init();
usb_task();
usb_wait_for_enumeration(); //Cihaz, hazır olana kadar bekle
if(usb_enumerated())
printf(lcd_putc,"f");
printf(lcd_putc,"Baglanti Kuruldu");
lcd_gotoxy(1,2);
printf(lcd_putc,"DS18B20 Okunuyor");
Sicaklik = ds1820_read(); //Sıcaklığı Oku...
printf(lcd_putc,"f"); // Ekranı sil...
lcd_gotoxy(5,1);
printf(lcd_putc,"Mucit23");
while(TRUE)
{
while(usb_enumerated())
{
if (usb_kbhit(1)) //Eğer pc'den yeni bir paket geldiyse
{
usb_get_packet(UcNokta1, paket, 64); //paketi oku
output_high(pin_a0);
}
lcd_gotoxy(1,2);
printf(lcd_putc,"SICAKLIK=%3.1f", Sicaklik);
lcd_putc(223);
lcd_putc("C ");
Term=Sicaklik*10;
Tam=Term/10;
Onda=Term%10;
paket[1]=Tam;
paket[2]=Onda;
usb_put_packet(UcNokta1, paket,64, USB_DTS_TOGGLE); // Datayı Gönder..
Sicaklik = ds1820_read();
}
}
}
Tümünü Göster