AnsweredAssumed Answered

NO interrupt working on STMF3

Question asked by Pink_Panther on Aug 7, 2015
Latest reply on Aug 10, 2015 by Clive One
Hey there,

I hope you can help with an issue I am facing.

I am working on the STM32F303RE with the SW4STM32 IDE by AC6. Additionally I have HTerm to get USART communication working with my PC.

I could not get any Interrupt working, neither with the USART, nor with any other module, so the following is the code I wrote to just get any interrupt working.
It does nothing more, than send the value of "A" through the USART1. The interrupt is supposed to just change this value. It is basically a "copy paste" from the examples out of the "STM32F30x_DSP_StdPeriph_Lib" folder. (The example is called "USART_DataExchangeInterrupt")

The problem here, and with every other interrupt is, that the program is working fine until I send a 8-bit value to change "A". At the moment the interrupt Handle should start is just leaves me with the:
"     b     Infinite_Loop"
and does never enter the USART1_IRQHandler.

I really hope, you guys can help.

Best wishes Alex

#include "stm32f30x.h"
 
uint16_t A;
 
int main(void)
{
    USART_InitTypeDef USART_InitStructure;
    NVIC_InitTypeDef NVIC_InitStructure;
    GPIO_InitTypeDef GPIO_InitStructure;
 
    /* Enable GPIO clock */
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);
 
    /* Enable USART clock */
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
 
    /* Connect PXx to USARTx_Tx */
    GPIO_PinAFConfig(GPIOC, GPIO_PinSource4, GPIO_AF_7);
 
    /* Connect PXx to USARTx_Rx */
    GPIO_PinAFConfig(GPIOC, GPIO_PinSource5, GPIO_AF_7);
 
    /* Configure USART Tx and Rx as alternate function push-pull */
    GPIO_InitStructure.GPIO_Mode    = GPIO_Mode_AF;
    GPIO_InitStructure.GPIO_Speed   = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_OType   = GPIO_OType_PP;
    GPIO_InitStructure.GPIO_PuPd    = GPIO_PuPd_UP;
    GPIO_InitStructure.GPIO_Pin     = GPIO_Pin_4;
    GPIO_Init(GPIOC, &GPIO_InitStructure);
 
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
    GPIO_Init(GPIOC, &GPIO_InitStructure);
 
    /* USARTx configuration ----------------------------------------------------*/
 
    USART_InitStructure.USART_BaudRate              = 115200;
    USART_InitStructure.USART_WordLength            = USART_WordLength_8b;
    USART_InitStructure.USART_StopBits              = USART_StopBits_1;
    USART_InitStructure.USART_Parity                = USART_Parity_No;
    USART_InitStructure.USART_HardwareFlowControl   = USART_HardwareFlowControl_None;
    USART_InitStructure.USART_Mode                  = USART_Mode_Rx | USART_Mode_Tx;
    USART_Init(USART1, &USART_InitStructure);
 
    /* NVIC configuration */
    /* Configure the Priority Group to 2 bits */
    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
 
    /* Enable the USARTx Interrupt */
    NVIC_InitStructure.NVIC_IRQChannel                      = USART1_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority    = 0;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority           = 0;
    NVIC_InitStructure.NVIC_IRQChannelCmd                   = ENABLE;
    NVIC_Init(&NVIC_InitStructure);
    //NVIC_EnableIRQ();
 
    /* Enable USART */
    USART_Cmd(USART1, ENABLE);
 
    USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
 
    A=0xAA;
 
    while(1){
        while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
        USART_SendData(USART1, A);
    }
}
 
void USART1_IRQHandler(void){
    if(USART_GetFlagStatus(USART1, USART_FLAG_RXNE) == SET){
        A=USART_ReceiveData(USART1);
    }
}

Outcomes