USB to COM converter


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1

    Question USB to COM converter

    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 (
    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

  2. #2
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by iugmoh View Post
    HSERIN [B0]
    Buffer[0] = b0
    You HSERIN, but how do you know anything is actually there?
    How do you know that your connections are is good?
    Or that your sending device is working properly?

  3. #3

    Default

    I make a new code to test hserin and hserout , I noted that Hserout working weill but HSERIN not getting any data, I sure that the connection is true but I think that there thing error in code , I don't know

    here is my code:

    ' 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

    __CONFIG _CONFIG5L, _CP0_ON_5L & _CP1_ON_5L & _CP2_ON_5L
    __CONFIG _CONFIG5H, _CPB_ON_5H
    endasm


    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 (
    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
    output portb.0
    high portb.0
    pause 1000
    low portb.0

    ' Main Program Loop

    MainLoop:
    HSERIN 1000,goo,[B0]
    high portb.0
    goo:
    HSEROUT ["send"]

    GOTO Mainloop
    end

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    did you tried without any USB?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by mister_e View Post
    did you tried without any USB?
    It always rolls right back to the basics...doesn't it...

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    nope.. i haven't talked about led blink yet
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. USB CDC Communications for Dummies!
    By Squibcakes in forum USB
    Replies: 104
    Last Post: - 15th January 2014, 13:43
  2. Simple USB Comms Problem
    By awmt102 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 6th January 2010, 20:17
  3. serial to usb converter
    By nicjo in forum Serial
    Replies: 3
    Last Post: - 17th September 2008, 23:52
  4. USB PIC without USB Connection
    By Tissy in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 26th December 2005, 17:39
  5. Serial to USB converter
    By jrt4fun in forum USB
    Replies: 6
    Last Post: - 8th August 2005, 15:14

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts