Ok, let's just go back to the original demo without any alteration:
Code:
' USB sample program for PIC18F4550 CDC serial port emulation
' Requires PBP 2.60 or later
' Compilation of this program requires that specific support files be
' available in the source directory. For detailed information, see
' the file PBP\USB18\USB.TXT.
ASM
CONFIG CPUDIV=NOCLKDIV ; CPU runing at full speed
CONFIG USBDIV=OFF ; Low speed USB clock diviser disabled, not used here
CONFIG FOSC=HS ; Use of High Speed crystal oscillator
CONFIG PLLEN=ON ; Enable PLL multiplier, 12Mhz oscilator x 4
CONFIG PCLKEN=ON ; Primary clock source is enabled
CONFIG FCMEN=OFF ; Failsafe clock off
CONFIG IESO=OFF ; Oscillator switchover mode disabled
CONFIG WDTEN=ON ; Watchdog timer on
CONFIG WDTPS=512 ; Watchdog divider is 512
CONFIG MCLRE=OFF ; Disable MCLR pin, enable RC3
CONFIG STVREN=ON ; Stack full/underflow will cause reset
CONFIG LVP=OFF ; Low voltage programming disabled
CONFIG BBSIZ=OFF ; 512kW block boot size
CONFIG XINST=OFF ; Extended instruction mode disabled
ENDASM
Include "cdc_desc.bas" ' Include the CDC descriptors
INCLUDE "USB_ASM_Service.pbp" ' USB Init and Service interrupt routines
'Define pin function
TRISA = %00000000 'PortA all digital output
TRISB = %00000000 'PortB all digital output
TRISC = %00000000 'PortC all digital output
ANSEL = %00000000 'Disable analog input on other pins
ANSELH = %00000000 'Disable analog input on other pins
'Define weak pullups
WPUA = %00000000 'No weak pullup on portA
WPUB = %00000000 'No weak pullup on portB
Define OSC 48
buffer Var Byte[16]
cnt Var Byte
'Pin function declaration
Pause 10
' USBInit ' Get USB going
' 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
Goto idleloop ' Wait for next buffer
... does not work.
I must say that after 2 days of digging the forum and the internet I am starting to get clueless about what to do to solve it. Is there a timer or an interrupt register to set up manually in order to run it properly? I could try to run it on a 18F4550 board I have but that won't solve the problem for my 13K50 project.
Also, I found out that USB_ASM_Service.pbp does not work in conjunction with INDT_INTS-18.bas and SPWM_INT.bas from Darell. I will need at least the latter, so maybe I should find another solution than actually trying to use USB_ASM_Service.pbp.
Any idea for troubleshooting this? or pointing to an interrupt solution that I could use? I'm starting to get clueless. Any help greatly appreciated!
BTW, I'm running PBP 2.60 in MCS 4.0.0.0, in conjunction with MPLAB 8.53.
Bookmarks