cancel
Showing results for 
Search instead for 
Did you mean: 

USB interrupt error

hsguja
Associate II
Posted on July 11, 2008 at 15:16

USB interrupt error

3 REPLIES 3
hsguja
Associate II
Posted on May 17, 2011 at 12:38

Hi,

I am trying to execute the mass storage demo application on hitex stm32 performance stick. When i execute the application and then plug the USB cable the code enters into the USB interrupt handler routine (USB_Istr) but the CTR bit in the ISTR is never set. The value i get on reading the ISTR is 0x2D00 (ERR bit is set) and if the USB cable is already plugged in before executing the application the value read from ISTR is 0x0D00 (ERR is clear). Due to this CTR_LP() is never called and PC shows the warning Unknown device detected. I have checked the clock configuration and it is correct since i can test the HID demo with same clock configuration.

I have tried to keep the initialization (RCC, NVIC, GPIO, EXTI and other)similar to HID application but it doesn't work.

Any clue?

thanks

Hemal

gommel
Associate II
Posted on May 17, 2011 at 12:38

Hello Hemal,

I have a related problem: When i restart my application (within rowley crossworks) the USB fires lots of interrupts - even if they are not enabled in the USB_CNTR register. THE USB_ISTR was set to 0x8b12 My first attempt was to reset the USB peripheral (USB_CNTR=1) which did NOT improve the situation. Next attempt was USB_ISTR=0 instruction ( just include ''usb_regs.h'' in the main.c and then _SetISTR(0);)

the situation improved a little bit but there was still the CTR interrupt from EP2 - (after resetting the whole MCU!!)

Then i added eight resets for the endpoints.

the final code for the ''real'' reset:

void USB_Reset()

{

_SetISTR( 0 );

_SetCNTR( 1 );

_ClearEP_CTR_RX( 0 );

_ClearEP_CTR_RX( 1 );

_ClearEP_CTR_RX( 2 );

_ClearEP_CTR_RX( 3 );

_ClearEP_CTR_RX( 4 );

_ClearEP_CTR_RX( 5 );

_ClearEP_CTR_RX( 6 );

_ClearEP_CTR_RX( 7 );

_SetCNTR( 0 );

}

and the right place to call it in main.c:

Set_USBClock();

USB_Reset(); //<<====

USB_Interrupts_Config();

USB_Init();

to my code which finally solved all the problems i had before.

My question to the guys at ST:

Why aren't the interrupt flags reset at the USB or MCU reset? Is this intentional or a bug of the peripheral?

lineatessile
Associate II
Posted on May 17, 2011 at 12:38

Dears,

I'm trying to use crosswork like you,

I found a problem with one function included in

usb_istr.c, it is CTR_LP(), this function is not

defined in any of the library I have.

Someone have an idea about this ??

thank for your help