AnsweredAssumed Answered

Help a Hardware guy with NVIC

Question asked by miller.dave on Feb 6, 2014
Latest reply on Feb 6, 2014 by miller.dave
I am trying to understand the NVIC on a SMT32F407. I have found that we are missing USB interrupts randomly. Since I cant solder a pullup to fix the problem I am stuck.
I can understand the documentation enough to be confused. I need a clear example of what to do.

This is what the software guys have cribbed from a whole bunch of examples and I am sure we have things setup wrong.

.DMA1 NVIC Setup
    NVIC_InitTypeDef NVIC_InitStructure;
    NVIC_InitStructure.NVIC_IRQChannel = DMA1_Stream0_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);


    USART2 NVIC setup
    NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;// we want to configure the USART1 interrupts
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;// this sets the priority group of the USART1 interrupts
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;// this sets the subpriority inside the group
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;    // the USART1 interrupts are globally enabled
    NVIC_Init(&NVIC_InitStructure);    // the properties are passed to the NVIC_Init function which takes care of the low level stuff


    TS NVIC Setup
    NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);


    USB
    NVIC_InitTypeDef NVIC_InitStructure;
    /* Enable USB Interrupt */
    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1 );
    NVIC_InitStructure.NVIC_IRQChannel = OTG_FS_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);

    USB Overcurrent
        /* Enable the Overcurrent Interrupt */
    //NVIC_InitStructure.NVIC_IRQChannel = HOST_OVRCURR_IRQn;
    //NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
    //NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
    //NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;


    TIM2

    NVIC_InitTypeDef NVIC_InitStructure;

    
    /* Configure the Priority Group to 2 bits */
    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2 );

    /* Enable the TIM2 gloabal Interrupt */
    NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

    NVIC_Init(&NVIC_InitStructure);


    TIM3
    NVIC_InitTypeDef NVIC_InitStructure;

    /* Enable the TIM3 global Interrupt */
    NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);

Why is the USB interrupt not firing?
How would you alter the numbers for success.

Thanks
Dave The frustrated hardware guy.


Outcomes