Correct software unplug device

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
dzairo
Rank 1
Rank 1
Posts: 35
Joined: Wed Sep 22, 2010 3:31 pm

Correct software unplug device

Post by dzairo » Mon Apr 11, 2011 11:41 am

Hi.
I have problem how to correct software unplug device from bus.
I have HId bootloader and HID device (my self program).
If plug device to USB then start bootloader and I can flash new program to MCU. if flash then jump to user program . then start my HID device and can send receive data from to USB , but I have special command to jump back to bootloader. there I have problem, I use easy function set watchdog and wait for watchdog reset MCU, it's work but still program for HID device show error so device is problem.
How can I correctly software unplug device from bus???

any idea??
regards

with special command I want jump from bootlaoder to user program and back

Alan Chatham
Rank 1
Rank 1
Posts: 28
Joined: Wed Sep 30, 2009 3:36 am
Location: Osaka, Japan
Contact:

Re: Correct software unplug device

Post by Alan Chatham » Wed Apr 13, 2011 2:08 am

So, I'm not sure how the HIDBootloader program resets the MCU when you've got the 'reset after program' box checked, but that would be the first place I'd start looking for trying to jump from the bootloader to your program. To get from your program to the bootloader, is the bootloader set to always go on after a MCU reset? Or do you have like an EEPROM flag that tells the program to go into the bootloader or run your code on startup, and if so, does that get set properly?

dzairo
Rank 1
Rank 1
Posts: 35
Joined: Wed Sep 22, 2010 3:31 pm

Re: Correct software unplug device

Post by dzairo » Sat Apr 16, 2011 11:25 am

Hi.
there is more way how to do it.
How I use this :
on first MCU start at bootloader mode. and control if is connected to USB or no . if is connect to USB then start normal bootloader if no then jump directly to main application.
and if main application detect USB then reset USB and start firmware. but I if want jump back to bootloader then is possible to jump direct or wait(1); and wait for watch dog reset .
now I use solution for watchdog reset , but I want try second way.
exist any way how to USB send special software function so I'm unplug , and physical don't unplug usb device is still in USB ???

regards

PS: if start MCU start than can read reset bit from MCU what MCU reset , from watch dog or from power on . and this bit can defined if run directly main application or bootloader.

Post Reply