PDA

View Full Version : Disable USB please help...



extoprak
- 25th February 2009, 21:41
Hi all,
I have a problem with 18f4550. I use pic basic pro and when I send information from pc, I want to show this info on 16-segments. But, in my experiences, if usb module is active, I can't use 16-segments ( I use 8 of 16-segment) In short, I have to save this incoming info at EEPROM, but again, if USB Module is active, it don't save on EEPROM :s ( I use "write")

My question is, how can I disable USB (to make save) or how can I make save when USB is active

please help me, this is my school project and I have to do this. I can transfer data by Visual basic and use it on 8 of leds, but I have to do it with 16-segment display.

Thanks

NOTE: I'm using Proteus 7.4 simulation, I don't know if a real 18f4550 can save while USB active.

mister_e
- 25th February 2009, 21:45
Seeing your code would help...

extoprak
- 25th February 2009, 22:08
I've just used the usb wizard ( this is'nt whole code, it's on my desktop, but this code don't work :(( )



TRISB =%00000000

DEFINE OSC 48
DEFINE LOADER_USED 1

'PORTB = 0

USBBufferSizeMax con 8 ' maximum buffer size
USBBufferSizeTX con 8 ' input
USBBufferSizeRX con 8 ' output

' the USB buffer...
USBBuffer Var Byte[USBBufferSizeMax]
USBBufferCount Var Byte


' ************************************************** **********
' * main program loop - remember, you must keep the USB *
' * connection alive with a call to USBService every couple *
' * of milliseconds or so... *
' ************************************************** **********
' initialise USB...

ProgramStart:

usbinit
gosub DoUSBIn
gosub DoUSBOut

write 0,USBbuffer[1] ' ******* or asd=usbbuffer[1] write 0,asd
'**don't save, why ?


Goto ProgramStart:

' ************************************************** **********
' * receive data from the USB bus *
' ************************************************** **********
DoUSBIn:
USBBufferCount = USBBufferSizeRX ' RX buffer size
USBService ' keep connection alive
USBIn 1, USBBuffer, USBBufferCount, DoUSBIn ' read data, if available
return

' ************************************************** **********
' * wait for USB interface to attach *
' ************************************************** **********
DoUSBOut:
USBBufferCount = USBBufferSizeTX ' TX buffer size
USBService ' keep connection alive
USBOut 1, USBBuffer, USBBufferCount, DoUSBOut ' if bus available, transmit data
return

mister_e
- 26th February 2009, 13:55
Do a little test...


HIGH LED
write 0,USBbuffer[1]
LOW LED

Use a scope to see if there's some activity on LED pin. If not, you may want to comment of of these to see where your program stuck


usbinit
gosub DoUSBIn
gosub DoUSBOut

I can't tell for Proteus, but I'm always impressed to see how rich students are ;)

extoprak
- 26th February 2009, 18:57
welll I confess, I'm using school computers, for Proteus :D ( I'm not rich :D )

I'll try it by real 4550 but, a little question, when I tried your USBDemo (mister_e), I realized that after resetting the pic, still the same leds are high ( some kind of save I think) but in your codes, there is no "write" command and I tried it with usb wizard just like my example, it works fine but when I reset the pic all leds are off. why yours are still on ?

mister_e
- 26th February 2009, 19:07
are you using my schematic?

extoprak
- 26th February 2009, 19:43
I don't know your sch. but, I've used a standart sch. I guess it was in micro code studio. easy hid wizard help. but I tried your USB Demo