Hi guys,
can you help me with program USB CDC Communicator on uC PIC18F47J53?
I never use USB, this is my first try.
I tried use the sample code from USB18 (CDC_demo). I tried rewrite the code but without success.
Thx.
Hi guys,
can you help me with program USB CDC Communicator on uC PIC18F47J53?
I never use USB, this is my first try.
I tried use the sample code from USB18 (CDC_demo). I tried rewrite the code but without success.
Thx.
Proglem solved:
Must use #congif for PIC.
' USB sample program for PIC18F47J53 CDC serial port emulation
' Requires PBP 2.60 or later
Include "cdc_desc.bas" ' Include the HID descriptors
Define OSC 48
#CONFIG
CONFIG WDTEN = OFF ;WDT disabled (enabled by SWDTEN bit)
CONFIG PLLDIV = 3 ;Divide by 3 (12 MHz oscillator input)
CONFIG STVREN = ON ;stack overflow/underflow reset enabled
CONFIG XINST = OFF ;Extended instruction set disabled
CONFIG CPUDIV = OSC1 ;No CPU system clock divide
CONFIG CP0 = OFF ;Program memory is not code-protected
CONFIG OSC = HSPLL ;HS oscillator, PLL enabled, HSPLL used by USB
CONFIG FCMEN = OFF ;Fail-Safe Clock Monitor disabled
CONFIG IESO = OFF ;Two-Speed Start-up disabled
CONFIG WDTPS = 32768 ;1:32768
CONFIG DSWDTOSC = INTOSCREF ;DSWDT uses INTOSC/INTRC as clock
CONFIG RTCOSC = T1OSCREF ;RTCC uses T1OSC/T1CKI as clock
CONFIG DSBOREN = OFF ;Zero-Power BOR disabled in Deep Sleep
CONFIG DSWDTEN = OFF ;Disabled
CONFIG DSWDTPS = 8192 ;1:8,192 (8.5 seconds)
CONFIG IOL1WAY = OFF ;IOLOCK bit can be set and cleared
CONFIG MSSP7B_EN = MSK7 ;7 Bit address masking
CONFIG WPFP = PAGE_1 ;Write Protect Program Flash Page 0
CONFIG WPEND = PAGE_0 ;Start protection at page 0
CONFIG WPCFG = OFF ;Write/Erase last page protect Disabled
CONFIG WPDIS = OFF ;WPFP[5:0], WPEND, and WPCFG bits ignored
#ENDCONFIG
buffer Var Byte[16]
cnt Var Byte
OSCTUNE.6 = 1 ' Enable PLL for 18F47J50 family
Pause 10
USBInit ' Get USB going
'************************************************* ***************
'* Set PORTA, PORTB, PORTC, PORTD PORTE to input/output *
'************************************************* ***************
TRISA = %00100010 ' Set PORTA to output
TRISB = %00001000 ' Set PORTB to output
TRISC = %00---000 ' Set PORTC to output
PortA = %00000000 ' Set PORTA to 0
PortB = %00000000 ' Set PORTB to 0
PortC = %00000000 ' Set PORTC to 0
PortD = %00000000 ' Set PORTD to 0
PortE = %00000000 ' Set PORTE to 0
'************************************************* ***************
'* SET LCD *
'************************************************* ***************
' Define LCD registers and bits
Define LCD_DREG PORTD
Define LCD_DBIT 4
Define LCD_RSREG PORTB
Define LCD_RSBIT 0
Define LCD_EREG PORTB
Define LCD_EBIT 1
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 1500
DEFINE LCD_DATAUS 50
Pause 1000 ' Wait for LCD to start up
'************************************************* ***************
'* LOOP *
'************************************************* ***************
' 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] = "O"
buffer[1] = "K"
buffer[2] = 13
buffer[3] = 10
buffer[4] = 0
outloop:
USBService ' Must service USB regularly
USBOut 3, buffer, 5, outloop
Goto idleloop ' Wait for next buffer
Hi.. I have windows 7 64bit machine... I download the 64_mchpcdc.inf provided by mackrackit...and copy and paste it in the Windows\sysWOW64 folder, I also reboot the machine but I'm getting exclamation icon(CDC - R232 Emulation Demo) in the devices and printers window. What do you think I'm doing bad? Please give advice.
Thanks in advance,
tacbanon
The driver provided with PBP now has 64 bit support added. So you do not need the one I linked to, although it should still work.
I think your problem might be that you copied it to a directory rather than letting the OS install it. Try deleting the file from the sysWOW directory, then do a reboot.
When your project is plugged into your PC windows should bring up the usual dialog asking to install a driver. Do not let windows look for it, point to where the file has been saved to and let windows do the installing. You then should see a virtual com-port in device manager.
Dave
Always wear safety glasses while programming.
Hello macrackit, thank you so much for replying...I got it working now.
Good day,
I have PBP 250_b running on a windows_7 64 bit.
What files are required in my PBP to update it to the 2.60 version and use the USB programs ?
Where could I download them ?
Thanks for helping
Ambrogio
You will have to go to MeLabs website and pay for the upgrade.
Dave
Always wear safety glasses while programming.
Bookmarks