Haberler:

Foruma Resim Yükleme ve Boyut Sınırlaması ( ! )  https://bit.ly/2GMFb8H

Ana Menü

PICBASIB PRO 18F2550 USB KONTROL

Başlatan kopfblut, 12 Ocak 2017, 14:58:11

kopfblut

Merhaba arkadaşlar pıc18f2550 ile usb den haberleşme yapmak istiyorum. Bunun için pbp daki örnek programı kullanıyorum ve Micro Code Studio ile derleme yapıyorum ama PC hiçbir şekilde donanımı bulamıyor.  donanımda led'im yanıp sönüyor.CONFIG ayarlarımı yanlış acaba. Daha önce USB'den bağlantı kurabilen var mı?





' Name        : USBCDC.pbp
' Compiler    : PICBASIC PRO Compiler 2.6
' Assembler   : MPASM
' Target PIC  : PIC18F2550 or similar type
' Hardware    : LAB-XUSB Experimenter Board
' Oscillator  : 20MHz external
' Keywords    : USBSERVICE, USBINIT, USBIN, USBOUT
' Description : PICBASIC PRO program for PIC18F4550 CDC serial port emulation.
' Compilation of this program requires that specific support files be available
' in the source directory. You may also need to modify the file USBDESC.ASM so
' that the proper descriptor files are included. For detailed information, see
' the file PBP\USB18\USB.TXT.
'

Include   "cdc_desc.bas"   ' Include the HID descriptors
asm
    __CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
    __CONFIG _CONFIG1H, _FOSC_HS_1H
    __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L &  _VREGEN_OFF_2L
    __CONFIG _CONFIG2H, _WDT_OFF_2H   
    __CONFIG _CONFIG3H, _MCLRE_OFF_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_OFF_3H   
    __CONFIG _CONFIG4L, _STVREN_OFF_4L & _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L   
    __CONFIG _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L & _CP2_OFF_5L & _CP3_OFF_5L 
    __CONFIG _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H 
    __CONFIG _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L & _WRT2_OFF_6L & _WRT3_OFF_6L
    __CONFIG _CONFIG6H, _WRTB_OFF_6H & _WRTC_OFF_6H  & _WRTD_OFF_6H
    __CONFIG _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L & _EBTR2_OFF_7L & _EBTR3_OFF_7L
    __CONFIG _CONFIG7H, _EBTRB_OFF_7H 

endasm   

Define OSC 48

buffer Var Byte[16]
cnt    Var Byte
LED    Var PORTB.7
   
   HIGH LED      ' LED ON
   pause 1000
   Toggle LED
   pause 1000
   Toggle LED
   
   USBInit
' Wait for USB input
idleloop:
   USBService   ' Must service USB regularly
  cnt = 16     ' Specify input buffer size
   USBIn 3, buffer, cnt, idleloop

' Message received
 

   buffer[0] = "H"
   buffer[1] = "e"
   buffer[2] = "l"
   buffer[3] = "l"
   buffer[4] = "o"
   buffer[5] = " "
   buffer[6] = "W"
   buffer[7] = "o"
   buffer[8] = "r"
   buffer[9] = "l"
   buffer[10] = "d"
   buffer[11] = 13
   buffer[12] = 10
   buffer[13] = 0

outloop:
   USBService           ' Must service USB regularly
   USBOut 3, buffer, 14, outloop
    LOw LED
   Goto idleloop        ' Wait for next buffer

   
   End

kopfblut

Arkadaşlar teşekkürler. Konuyu siz değerlendirmeden çözdüm. CONFIG ayarlarında ciddi sıkıntı varmış. Düzeltilmiş listesi aşağıda


asm
    __CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
    __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
    __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L &  _VREGEN_ON_2L
    __CONFIG _CONFIG2H, _WDT_ON_2H   
    __CONFIG _CONFIG3H, _MCLRE_ON_3H  & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_OFF_3H   
    __CONFIG _CONFIG4L, _STVREN_OFF_4L & _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L   
    __CONFIG _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L & _CP2_OFF_5L & _CP3_OFF_5L 
    __CONFIG _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H 
    __CONFIG _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L & _WRT2_OFF_6L & _WRT3_OFF_6L
    __CONFIG _CONFIG6H, _WRTB_OFF_6H & _WRTC_OFF_6H  & _WRTD_OFF_6H
    __CONFIG _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L & _EBTR2_OFF_7L & _EBTR3_OFF_7L
    __CONFIG _CONFIG7H, _EBTRB_OFF_7H 

endasm