cancel
Showing results for 
Search instead for 
Did you mean: 

USB HOST Interrupt

irmakci
Associate II
Posted on March 17, 2013 at 03:42

Hello...

Now i design USB Host System. In the system there are 2 button interrupts, USB Host Interrupt. I use STM32_F105-07_F2xx_USB-Host-Device_Lib_V2.0.0 libraries and stm32f105...

In the system, i sometimes disable and enable button interrupts when i enter interrupt routine of button and when i enter USB Process function of USB libraries... i use system clock 8MHz for my system and PLL for my USB Host Clock...

NVIC priorities is as follows: 

1- Button interrupts(for each two) : 

    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3;

    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

2- my USB board support package configuration : 

   Timer : 

  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;

  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

   USB Global Int. 

  NVIC_InitStructure.NVIC_IRQChannel = OTG_FS_IRQn; 

  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 5;

  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

And my button enable disable code is follows : 

void STM32_UP_Button_OnOff(FunctionalState NewState)

{    

    EXTI_InitTypeDef EXTI_InitStructure;

    /* Initializes the EXTI_InitStructure */

    EXTI_StructInit(&EXTI_InitStructure);

    EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

    EXTI_InitStructure.EXTI_Line = UP_BUTTON_EXTI_LINE;

    EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

    EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;   

  

    //EXTI_ClearITPendingBit(UP_BUTTON_EXTI_LINE );

    /* Disable the DOWN_BUTTON_EXTI_LINE on falling edge */

    if(NewState == DISABLE)

    {

        

        EXTI_InitStructure.EXTI_LineCmd = DISABLE;

        

    }

    /* Enable the EXTI DOWN_BUTTON_EXTI_LINE on falling edge */

    else

    {

        /* Clear the the DOWN_BUTTON_EXTI_LINE interrupt pending bit */

        //E

        EXTI_InitStructure.EXTI_LineCmd = ENABLE;

    }

    EXTI_Init(&EXTI_InitStructure);

              

}

The problem is that when program works in USBH_USR_MSC_Application function, the button enable/disable does not work even if i see that  External Interrupt Mask Register sets register in Keil... i can not enter button interrupts even if i enable button interrupts in USBH_USR_MSC_Application function? i want to change my enable, disable status in this function but i could not... 

Thanks in advance

Best regards

#stm32-usb-host
17 REPLIES 17
irmakci
Associate II
Posted on March 18, 2013 at 01:17

problem still goes on... any suggestion?

Thanks in advance

Posted on March 18, 2013 at 03:57

Well I'm not totally clear about what is or is not going on here, I don't think I have enough info to duplicate. Consider a better presentation/explanation.

Do the EXTI interrupts ever work? If not, how are they configured in totality, not a selective summary.

Is it reasonable to use EXTI_Init() to do this, or should you be changing individual bits in the EXTI peripheral.

Could you turn the on/off via the NVIC, or a variable that flags enablement?
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
irmakci
Associate II
Posted on March 18, 2013 at 14:14

Problem  : i want to enable and disable USBH_Process(&USB_OTG_Core, &USB_Host) function with a FLAG... and i enable or disable this flag via my external interrupt routines. For example, when i click YES, TRANSFER button, i enable this Flag to enter USB_Process function and when i click NO TRANSFER button , i disable this Flag. Normally, i can enable or disable button interrupts in the program but i can not enable or disable in the USB_Process->USBH_USR_MSC_Application function. i tried with only External Interrupt Mask, after this via NVIC but again no result...

 

1. if i can disable only external interrupts via mask registers, i think it must be disabled? and it will not come to NVIC?

i mean when i want to disable or enable external interrupt, should i enable or disable both NVIC and EXTI->IMR ? or only EXTI->IMR is enough?

2 I use board support package to disable USB interrupts, USB Power port for low power application, it can be problem for my application when i sometimes open and close my USB Power port?

3.  And i think i use default USB port configuration. i do not need to make other configuration like making GPIO configuration. For example for interrupt port, we make some configuration for floating input etc. but for USB, is it default?

  RCC_OTGFSCLKConfig(RCC_OTGFSCLKSource_PLLVCO_Div3);

  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_OTG_FS, ENABLE) ;

Posted on March 18, 2013 at 15:12

Do the EXTI interrupts ever work? This is a pretty basic/fundamental question, let's start with it first.

Do you have the AFIO clock enabled in your F105 chip?
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
irmakci
Associate II
Posted on March 18, 2013 at 16:22

application starts , yes it works... i can enter ext interrupts. and i change a flag in this interrupt. but after entering USR_App. in the USB process function, i can not change enable disable status of ext. interrupts...

RCC_APB2PeriphClockCmd(DOWN_BUTTON_CLK | RCC_APB2Periph_AFIO, ENABLE);

this is part of AFIO...

but i noticed something... in the past, i had the same problem with 1 timer... when i close timer, my button interrupts worked... i speak about other part of code... 

Thanks in advance...

irmakci
Associate II
Posted on March 18, 2013 at 16:24

this is my main part

        if (Main_Data.USBWriteFlag)

        {

          USBH_Process(&USB_OTG_Core, &USB_Host);

        }

Posted on March 18, 2013 at 16:32

Ok, and the purpose of disabling them is what? Could you not just leave them enabled, and handle whatever state transitions you need based on your current state? Ignoring them if required.

I'm not sure how you're debugging this, but when trying to understand dynamic system interactions I tend to output telemetry out of a serial port or via a screen.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
dthedens23
Associate II
Posted on March 18, 2013 at 16:37

Using an interrupt on a button can be an issue.

Buttons cause mechanical bounce and can display ugly signals when viewed on a scope,

do the buttons employ de bounce circuitry?

Posted on March 18, 2013 at 16:52

I'm fishing, and playing 20 questions to draw out an understanding of the system. I'm a savant, not a telepath.

I would contend that disabling an EXTI sourced interrupt, in the IRQHandler itself would be trivially easy to do.

As the USB Handler is being pumped repetitively in a while(1) loop, one could also poll the buttons.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..