Using MC9S08JM60 chip and DEMOJM Kit, I wrote a software in C# similar to the Freescale GUI for USB application Training, which can be found in the following link:
In the microcontroller code I used the firmware example in the above link and wrote my functions for the keyboards in it.
Now the problem is when I use an external power supply and disconnect the USB cable, the keys are not functioning at all as there are when the USB cable is connected. I have found out that the function in main.c called Check_USBBus_Status() is causing this issue. I don't exactly know how this function helps the keyboards interrupt to fail. When I remove the function, the USB port won't work even when the connection exists.
It is so appreciated if someone let me know how I am going to fix this problem.