cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F2XX Interrupts

stephan239955_st
Associate II
Posted on May 30, 2011 at 20:36

I have recently ported an application from the STM32F107 to the STM32F217 using the CrossWorks from Rowley tool chain.  My '107 project builds and runs correctly.  Amongst other things this project uses interrupts to monitor the serial port and some GPIOs.  Unfortunately I can't get any of these interrupts to function with my '217 board.  I am using the STM32F2xx Standard Peripherals Library and I have included my serial port configuration below. 

{

USART_InitTypeDef USART_InitStructure;

NVIC_InitTypeDef NVIC_InitStructure;

GPIO_InitTypeDef GPIO_InitStructure;

USART_ClockInitTypeDef  USART_ClockInitStructure;

// 1.

    RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);

// 2.

    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);

// 3.

    GPIO_PinAFConfig(GPIOD, GPIO_PinSource5, GPIO_AF_USART2);

    GPIO_PinAFConfig(GPIOD, GPIO_PinSource6, GPIO_AF_USART2);

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;

    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; 

    GPIO_Init(USART2, &GPIO_InitStructure);

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;

    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; 

    GPIO_Init(USART2, &GPIO_InitStructure);

// 4.

    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(USART2, USART_InitStruct);

// 5

    NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;

    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = configLIBRARY_KERNEL_INTERRUPT_PRIORITY;

    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

    NVIC_Init( &NVIC_InitStructure );

    USART_ITConfig( USART2, USART_IT_RXNE, ENABLE );

// 6.

// No DMA

// 7.

    USART_Cmd(USART2, ENABLE);

// 8.

// No DMA

}

Does anyone know if there is some sort of global interrupt enable added to the STM32F2xx library?  I know I am missing something in regards with interrupts but I can't figure out what.  Any help is appreciated.

Steph

3 REPLIES 3
stephan239955_st
Associate II
Posted on May 30, 2011 at 20:53

In my post above I mentioned that I was having problems with all interrupts including those from GPIO pins.  Well I have resolved this problems by adding the function,

RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);

...before configuring the EXTI line. This is documented in the stm32f2xx_exti.c preamble.  That resolves some of my issue.  Still working away on the USART. 

Thanks.

stephan239955_st
Associate II
Posted on May 31, 2011 at 15:13

Ugh...  that should read....

// 3.

    GPIO_PinAFConfig(GPIOD, GPIO_PinSource5, GPIO_AF_USART2);

    GPIO_PinAFConfig(GPIOD, GPIO_PinSource6, GPIO_AF_USART2);

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;

    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; 

    GPIO_Init(GPIOD, &GPIO_InitStructure);

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;

    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; 

    GPIO_Init(GPIOD, &GPIO_InitStructure);

I have actually been able to detail the problem (even with the above fix) more specifically to the serial port in general.  Ill regardless of the interrupts I cannot transmit any data out the USART.  I will be probing the hardware shortly.
stephan239955_st
Associate II
Posted on May 31, 2011 at 23:56

Another typo...

    USART_Init(USART2, &USART_InitStruct);

...and that seem to solve my problem.  It was not interrupt related at all just human error (me) when configuring the usart.