I want to detect USB disconnection on MCF52259. My purpose is that when somebody physically pulls the usb wire from the mcf52259, I need to reset the device.
Thanks for the help.
That is a Dual Mode controller. It can run as a Host or a Device. Which one are you using it for?
If running as a device and powered from Ethernet, that would happen automatically.
What software are you running to handle the USB? It should have a hook or a function that is called when the disconnect happens. You should be able to hook that and then set the SOFTRST bit - see "11.5.1 Reset Control Register (RCR)".
Thanks for the reply.
USB controller is running in device mode.
I am not using ethernet at all.
Also, I am not running any software. I am using my own firmware software.
Should I reset the MCF52259 device during usb reset event.
Oops. I meant to type "if powered from USB" like a USB key or hard disk.
If you're using your own software, then you get to do whatever you want to do.
> Should I reset the MCF52259 device during usb reset event.
What is a "usb reset event"? Maybe you should explain why you want to reset the device? What is it? Does it do anything when not connected to the host? Something like a USB Stick obviously doesn't. Other things like cameras that are connected to PCs go back to being cameras. What's your case?
If you do want to reset the CPU from software then use the SOFTRST bit.
My usb device is not powered by usb bus. I am applying the external power to it.
What I want to do is that whenever the user pulls the usb cable out, then the usb device should reset the CPU. I know how to reset the CPU by using the software reset.
What I do not know is that in which usb interrupt status should I reset the CPU.
> My usb device is not powered by usb bus. I am applying the external power to it.
Yes I know that. Powered ones obviously power off when unplugged and reset-and-start when plugged in. I was asking you you wanted to emulate that with your device.
> What I do not know is that in which usb interrupt status should I reset the CPU.
Find some example code for USB on Freescale parts. See what they do.
I assume you're meaning the interrupts in "126.96.36.199 OTG Interrupt Status Register (OTG_INT_STAT)"? There's only 5 active bits, and they're pretty well described. Since you've said you're a "B Device" then I'd guess "B_SESS_CHG - This bit is set when a change in VBUS is detected on a B device.". But it wouldn't take you long to see which ones work by trial and error.
The interrupt tells you something has changed. You then have to look at the status bits behind the interrupt to see if it was for the voltage going on or off, in this case the bits in "188.8.131.52 Interrupt Status Register (OTG_STAT)". You don't have to enable the interrupt if your code can work by polling though.
Retrieving data ...