cancel
Showing results for 
Search instead for 
Did you mean: 

OTG FS IRQChannel not ''recognized'' by F105RBT6?

StephanMair
Senior
Posted on May 13, 2014 at 04:46

I'm working on a project based on the V2.10 Host lib.

When trying to enable global interrupt for OTG FS, the program enters the hardware fault ''loop of death''(the notorious HardFault_Handler in stm32f10x_it.c)

Problematic codes:

void USB_OTG_BSP_EnableInterrupt(USB_OTG_CORE_HANDLE *pdev)

{

  NVIC_InitTypeDef NVIC_InitStructure;

 

  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);

  NVIC_InitStructure.NVIC_IRQChannel = 67;

  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;

  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;

  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

  NVIC_Init(&NVIC_InitStructure); 

...

}

In debug mode, I pinpointed the actual code that's responsible: (in misc.c)

  /* Enable the Selected IRQ Channels --------------------------------------*/

    NVIC->ISER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] =

      (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F);

So I'm thinking the value ''67'', which according to a .c file in the V2.10 library should be the channel number for I\OTG FS global interrupt, clearly isn't working out for F105.

So why am I using this value ''67'' instead of #include certain files in the V2.10 lib, and let the compiler work out the rest? Because that would complicate my project. I would have to inevitably include a lot of things that I don't really want by doing that.

I know it's not ''standard practice'' to right click and use ''go to definition'' to find this value ''67'',  but I tried other ST documents, as always, the ST documents are painfully unorganized and the UM0427 did not even give the value for OTG IRQ channels. Table 274. NVIC_IRQChannels ended with ''DMA2_Channel4_5_IRQChannel''.

So could anyone please help me? Maybe I shouldn't use this value directly (which is highly improbable)? Or this value is wrong, should be something else?
2 REPLIES 2
Posted on May 13, 2014 at 05:08

Not sure I fully grasped what was being asked, but

The 105/107 are from the Connectivity series, they require the define STM32F10X_CL on the command line to the compiler, or within the project Also required is the correct start up file for the processor STM32_USB-Host-Device_Lib_V2.1.0\Libraries\CMSIS\Device\ST\STM32F10x\Source\Templates\arm\startup_stm32f10x_cl.s STM32_USB-Host-Device_Lib_V2.1.0\Libraries\CMSIS\Device\ST\STM32F10x\Include\stm32f10x.h

/**
* @brief STM32F10x Interrupt Number Definition, according to the selected device
* in @ref Library_configuration_section
*/
typedef enum IRQn
{
/****** Cortex-M3 Processor Exceptions Numbers ***************************************************/
NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */
MemoryManagement_IRQn = -12, /*!< 4 Cortex-M3 Memory Management Interrupt */
BusFault_IRQn = -11, /*!< 5 Cortex-M3 Bus Fault Interrupt */
UsageFault_IRQn = -10, /*!< 6 Cortex-M3 Usage Fault Interrupt */
SVCall_IRQn = -5, /*!< 11 Cortex-M3 SV Call Interrupt */
DebugMonitor_IRQn = -4, /*!< 12 Cortex-M3 Debug Monitor Interrupt */
PendSV_IRQn = -2, /*!< 14 Cortex-M3 Pend SV Interrupt */
SysTick_IRQn = -1, /*!< 15 Cortex-M3 System Tick Interrupt */
/****** STM32 specific Interrupt Numbers *********************************************************/
WWDG_IRQn = 0, /*!< Window WatchDog Interrupt */
PVD_IRQn = 1, /*!< PVD through EXTI Line detection Interrupt */
TAMPER_IRQn = 2, /*!< Tamper Interrupt */
RTC_IRQn = 3, /*!< RTC global Interrupt */
FLASH_IRQn = 4, /*!< FLASH global Interrupt */
RCC_IRQn = 5, /*!< RCC global Interrupt */
EXTI0_IRQn = 6, /*!< EXTI Line0 Interrupt */
EXTI1_IRQn = 7, /*!< EXTI Line1 Interrupt */
EXTI2_IRQn = 8, /*!< EXTI Line2 Interrupt */
EXTI3_IRQn = 9, /*!< EXTI Line3 Interrupt */
EXTI4_IRQn = 10, /*!< EXTI Line4 Interrupt */
DMA1_Channel1_IRQn = 11, /*!< DMA1 Channel 1 global Interrupt */
DMA1_Channel2_IRQn = 12, /*!< DMA1 Channel 2 global Interrupt */
DMA1_Channel3_IRQn = 13, /*!< DMA1 Channel 3 global Interrupt */
DMA1_Channel4_IRQn = 14, /*!< DMA1 Channel 4 global Interrupt */
DMA1_Channel5_IRQn = 15, /*!< DMA1 Channel 5 global Interrupt */
DMA1_Channel6_IRQn = 16, /*!< DMA1 Channel 6 global Interrupt */
DMA1_Channel7_IRQn = 17, /*!< DMA1 Channel 7 global Interrupt */
#ifdef STM32F10X_LD
..
#endif /* STM32F10X_LD */
#ifdef STM32F10X_LD_VL
..
#endif /* STM32F10X_LD_VL */
#ifdef STM32F10X_MD
..
#endif /* STM32F10X_MD */
#ifdef STM32F10X_MD_VL
..
#endif /* STM32F10X_MD_VL */
#ifdef STM32F10X_HD
..
#endif /* STM32F10X_HD */
#ifdef STM32F10X_HD_VL
..
#endif /* STM32F10X_HD_VL */
#ifdef STM32F10X_XL
..
#endif /* STM32F10X_XL */
#ifdef STM32F10X_CL
..
CAN2_RX0_IRQn = 64, /*!< CAN2 RX0 Interrupt */
CAN2_RX1_IRQn = 65, /*!< CAN2 RX1 Interrupt */
CAN2_SCE_IRQn = 66, /*!< CAN2 SCE Interrupt */
OTG_FS_IRQn = 67 /*!< USB OTG FS global Interrupt */
#endif /* STM32F10X_CL */
} IRQn_Type;

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
StephanMair
Senior
Posted on May 13, 2014 at 08:38

Thank you for your timely reply clive.

This is what I meant: To enable the OTG FS Global interrupt, we need to tell the compiler which channel to open up. I looked up the index/number for that channel using very unprofessional (will get back on that in a bit) method, which is right clicking

OTG_FS_IRQn

and then ''go to definition'' (I'm using Keil BTW). And eventually, as shown in the last few lines of your post, the corresponding value of

OTG_FS_IRQn

is So I just put 67 to the right of '' NVIC_InitStructure.NVIC_IRQChannel = 67;'' in hoping everything could work out, but it turned out that it did not. And I'm asking why, which part of this did I do wrong? I mean do I have to #include the right files and put ''

OTG_FS_IRQn

'' instead of ''67''? As for why I didn't just #define -ed what files I want to include/use, that's a long story, I kinda messed up, but I can assure you that everything else went fine, and I'm quite confident the problem is with that exact line in my previous posts which was trying to open up/enable the OTG_FS interrupt channel.