Me again,
I have been working on a program which uses the Mini32 board and has been communicating with USB quite nicely all along but after a while working on various areas of the code I noticed an error popping up saying that the USB Device has malfunctioned.
I have systematically remmed out all cod not related to the USB and even pasted the functions into the sample file for the MINI32 and to ne avail.
If I load the MINI Polling sample, the chip communicates just fine. I have checked and rechecked the settings and even pasted the whole source into the working sample and then it stops again.
USB has stopped working
-
- Posts: 78
- Joined: 17 Jun 2008 13:38
USB has stopped working
Last edited by bobspencerr on 10 Jun 2013 23:57, edited 1 time in total.
Re: USB has stopped working
hello Bob, at what speed is data coming in? i see you have several delay_ms() calls in you loop, could it be this is to slow?
From my experience it is also good use to set the IP_level of your interrupt even if this would be the only ISR
From my experience it is also good use to set the IP_level of your interrupt even if this would be the only ISR
Au royaume des aveugles, les borgnes sont rois.
-
- Posts: 78
- Joined: 17 Jun 2008 13:38
Re: USB has stopped working
Thanks for the reply JPC.
I have used the Interrupt Assistant to create the code for the USB so Im not sure how to use the IP_Level other than specifying the ILevel in the header.
I wouldnt have thought that long delays in the main body of the code word affect the USB interrupt function as it is designed to break out of long code when it occures, isnt it?
Thanks for your input, I appreciate it.
By the way, as I said, I removed all code and left only the main USB functionality and it still didnt work.
I have used the Interrupt Assistant to create the code for the USB so Im not sure how to use the IP_Level other than specifying the ILevel in the header.
I wouldnt have thought that long delays in the main body of the code word affect the USB interrupt function as it is designed to break out of long code when it occures, isnt it?
Thanks for your input, I appreciate it.
By the way, as I said, I removed all code and left only the main USB functionality and it still didnt work.
Re: USB has stopped working
it is in fact one of the weaknesses of the interrupt assistant, it does not set the priority level but only informs the compiler on this probably to allow it to decide what registers to save and restore inside the interrupt, it is the users responsability to set the IP_leven accordingly so if you have it declared at IPLevel 7 you should set this before enabling the interrupts in the init-section.
The most readable way is to use something like
The interrupt will deal with each packet as it arrives but with the long delays might overwrite earlyer packet before it is processed, you would need some extra buffering to solve this.
The most readable way is to use something like
Code: Select all
USBIP0_bit := 1;
USBIP1_bit := 1;
USBIP2_bit := 1;
Au royaume des aveugles, les borgnes sont rois.
-
- Posts: 78
- Joined: 17 Jun 2008 13:38
Re: USB has stopped working
JPC You sir are a legend.
It fixed it instantly. I cant thank you enough for your help. I have spent three days working on this and you just got it right straight away.
Thank you very much.
It fixed it instantly. I cant thank you enough for your help. I have spent three days working on this and you just got it right straight away.
Thank you very much.
Re: USB has stopped working
Hi,
If you carefully read the Interrupts topic in the Help file, you will see the Interrupt Coding Requirements :
Filip.
If you carefully read the Interrupts topic in the Help file, you will see the Interrupt Coding Requirements :
Regards,1. Write the Interrupt Service Routine. You may use Interrupt Assistant to easily write this routine.
2. Initialize the module which will generate an interrupt.
3. Set the correct priority and subpriority for the used module according to the priorities set in the Interrupt Service Routine.
4. Enable Interrupts.
Filip.
Re: USB has stopped working
Filip,
it has been suggested before, the interrupt assistant could provide at least a template that suggest the user to fill in these priority bits or even better generate the code for this. The interrupt assistant as it currently exists is a bit misleading as starters think all is done after the assistant pasted the (incomplete) code in their application.
it has been suggested before, the interrupt assistant could provide at least a template that suggest the user to fill in these priority bits or even better generate the code for this. The interrupt assistant as it currently exists is a bit misleading as starters think all is done after the assistant pasted the (incomplete) code in their application.
Au royaume des aveugles, les borgnes sont rois.
Re: USB has stopped working
I agree with jpc on this. I ran into this same issue a while ago with UART interrupts, and spent a significant amount of time getting to the bottom of it.
If you know what you're doing, you're not learning anything.
Re: USB has stopped working
Hi,
OK, thank you for your suggestion, I will pass it to our developers.
Regards,
Filip.
OK, thank you for your suggestion, I will pass it to our developers.
Regards,
Filip.