usb to serial and back on the fly with ucase$


Closed Thread
Results 1 to 18 of 18

Hybrid View

  1. #1

    Default usb to serial and back on the fly with ucase$

    Ok I was thinking of a little project to test the old grey cells and to finally how to learn how to use USB as i am planning to need it soon, and sooner jump into a big project this seems easier....


    Set usb on the pic to appear to windows as a virtual com-port


    if available, read a character, from the virtual com-port, convert it to upper case, and then output it at 9600 via the hwuart....

    and....

    if available, read a character, from the hwuart , convert it to upper case, and then output it at 9600 via the virtual com-port


    continue till the worlds end.

    Now its all simple when written down, and i can easily achieve this if it was using the hwuart and a swuart, but i am lost with the usb side.

    I think i'm in the same boat as alot of people on this, so can we do this simply, if usb is such a thing.....

    I know there are lots of easy this and that and HIDeous things around, but the keyword is simple.....

    Got a spare 18f2550 and a 4mhz crystal here i think may be just the ticket

  2. #2

    Default

    ok had a look at MCS and easyhid, tried to compile the output it generated, but i got an error that pbppic18.lib could not be found.


    i added a line near the top, include ''pbppic18.lib'' but now get an error a redefinition of label of [ifndef]

    never easy is it, even when its called easy.....

  3. #3

    Default it still hates me...

    Ok i found the easy cdcusb demo thingy....(technically minded me)

    i eventually got it all copiling without errors once i fixed the paths in the 'incs'

    but....

    now i have another issue...

    this is a segment of my test code

    Code:
        portb=16+8
        pause 1000
        portb=8+1
        pause 1000
        USBInit
        portb=8

    It gets to ubinit with all being fine, then the lights go out, and thats the end of it.....

    if it was waiting at usbinit or stuck at it i would expect the lights to stay on...


    anyone know why that happens, windows does nothing either.

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    It looks like the External USB Transceiver pins are active. (VPO VMO etc.)

    Have you changed the UCFG register?
    You should not.

    DT

  5. #5

    Default

    Quote Originally Posted by Darrel Taylor View Post
    It looks like the External USB Transceiver pins are active. (VPO VMO etc.)

    Have you changed the UCFG register?
    You should not.
    it has a ucfg register? i just downloaded the usbcdc demo and compiled it, when i said i fixed the incs i meant the inc issue with the 18f2550 fuses and the invalid path in one of the incs i found.



    by flashing the leds on portb etc i know i am running internally at the right speed so my clock divs are ok.

    all i have is pic on a board with leds on the ports and a usb connector, nothing fancy, was hoping to achive success with the KISS principle..

    precompiled stuff seems to work, i used this board about two years ago with the simple usb demo, but i need to make it do serial...

    I did just find another path {c:\pbp\pic¬1.47\} that i need to edit but the phone just went and i have to go drive someone shopping!

    thanks for the reply, i'll update when they stop dragging me back to the real world

  6. #6

    Default

    ok now i want to scream at it..........

    Code:
    buffer	Var	Byte[16]
    cnt	Var	Byte
    flash var byte   
    
    LED0	Var	PORTB.0
    LED1	Var	PORTB.1
    LED2	Var	PORTB.2
    LED3	Var	PORTB.3
    LED4	Var	PORTB.4
     
    CMCON = 7            ; turn off comparators 
    ADCON1 = 15            ; turn off analog inputs
    
    define OSC 48
    
    trisa=0
    trisb=0
    
        high led0
        high led1
        high led2
        high led3
        high led4
    
    pause (1000)
        low led4
    pause (1000)
        low led3
    pause (1000)
        low led2
    pause (1000)
        low led1
    pause (1000)
        low led0
    pause (1000)  ; end of the pretty countdown
    
    
        portb=9
        pause 1000
       ; usbinit
        portb=8 
        pause 1000   ; never gets to here if i un-rem usbinit
        portb=16
    
    ; Wait for USB input
    idleloop:
    ;   USBService	' Must service USB regularly
    ;	cnt = 16	' Specify input buffer size
        
        if flash=0 then
    	portb=1
    	flash=1
    	else
    	portb=0
    	flash=0
    	endif
    ;	
    ;   USBIn 3, buffer, cnt, idleloop
    
    pause 1250
        goto idleloop
    with the usb bits rem'd out, the led's flash as expected, as soon as i un=rem usbinit, it hangs at usbinit

  7. #7

    Default

    actually, after displaying '9' on portb, it goes immeditaly to showing '1', and i mean immediate, no one second pause displaying '8'

    to get to '1' it must pass '8', but then if it got to '1', it should flash between '1' and '0'.........and it does not - ant that last pause is 125 not 1250........

    now i am confused

Similar Threads

  1. USB CDC Communications for Dummies!
    By Squibcakes in forum USB
    Replies: 104
    Last Post: - 15th January 2014, 13:43
  2. Raw serial data sniffer? By USB??
    By kevj in forum General
    Replies: 1
    Last Post: - 5th July 2008, 14:34
  3. Advice please - Warning message
    By malc-c in forum mel PIC BASIC Pro
    Replies: 50
    Last Post: - 23rd January 2007, 13:20

Members who have read this thread : 1

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