Page 1 of 1

Correct software unplug device

Posted: Mon Apr 11, 2011 11:41 am
by dzairo
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

Re: Correct software unplug device

Posted: Wed Apr 13, 2011 2:08 am
by Alan Chatham
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?

Re: Correct software unplug device

Posted: Sat Apr 16, 2011 11:25 am
by dzairo
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.