Hi all,
after I finished our USBMOUSE and USBKeyboard successfully , I try to make usb to com converter so I try USBCDC emulator example , so now I can send from usb to com but I can't recive from COM to our usb so I think there is wrong in Hserin section, if anyone have hint to help me
here is my code , I use PIC18F4455 with 20MHZ crystal , at baud rate 9600bps
' Pic Configuration
' =================
asm
__CONFIG _CONFIG1L, _USBDIV_2_1L & _CPUDIV_OSC1_PLL2_1L & _PLLDIV_5_1L
__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_ON_1H & _IESO_OFF_1H
__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _BORV_2_2L & _VREGEN_ON_2L
__CONFIG _CONFIG2H, _WDT_OFF_2H
__CONFIG _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_ON_3H
__CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
endasm
INCLUDE "DT_INTS-18.bas" ; Base Interrupt System
INCLUDE "ReEnterPBP-18.bas" ; Include if using PBP interrupts
DEFINE OSC 48
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 20h
DEFINE HSER_BAUD 9600
DEFINE HSER_CLROERR 1
' USB module
' ----------
UCFG var byte EXT ' include UCFG register... Yeah Melabs didn't :o(
ucfg = %00010100 ' enable internal USB pull-up, Full speed USB
' ANALOG I/O CONFIG
' -----------------
ADCON1 = 15 ' Set all I/Os to Digital
CMCON = 7 ' Disable Comparator
Buffer VAR BYTE[8]
Cnt VAR BYTE
B0 VAR BYTE
ASM
INT_LIST macro ; IntSource,Label,Type,ResetFlag?
INT_Handler RX_INT,_SendUsB,PBP,yes
endm
INT_CREATE ; Creates the interrupt processor
INT_ENABLE RX_INT ; enable external (RX) interrupts
ENDASM
USBInit
' Main Program Loop
MainLoop:
USBService ' Must service USB regularly
Cnt = 8
USBIn 3, Buffer, Cnt, MainLoop
HSEROUT [STR Buffer\Cnt]
GOTO Mainloop
'---[RX_INT - interrupt handler]------------------------------------------------
' PROGRAM COMES HERE WHEN DATA ENTERS THE USART PORT
SendUsB:
HSERIN [B0]
Buffer[0] = b0
cnt = 1
OutLoop:
USBService ' Must service USB regularly
USBOut 3, Buffer, Cnt, OutLoop
@ INT_RETURN