2015-08-07 01:13 PM
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);
}
}
#stm32f3
2015-08-07 02:09 PM
Using a .CPP file by chance?
2015-08-07 02:21 PM
2015-08-08 01:04 AM
Double check the vector table.
* are all vector defined ? * does the vector definition match your part ? * did you write the name of the handler correctly (case matters) ?2015-08-10 03:56 AM
Hey Guys,
thanks for your help, I think I found the mistakte. The vektor table looks like below. To me it seems like they forgot to manage this stuff before release, as every other Lib has it working pretty well. Might be they update this, but for now, I think handling this topic might take to much time. Best wishes Alex/******************************************************************************
*
* The minimal vector table for a Cortex-M. Note that the proper constructs
* must be placed on this to ensure that it ends up at physical address
* 0x0000.0000.
*
******************************************************************************/
.section .isr_vector,
''a''
,%progbits
.type g_pfnVectors, %object
.size g_pfnVectors, .-g_pfnVectors
g_pfnVectors:
.word _estack
.word Reset_Handler
.word NMI_Handler
.word HardFault_Handler
.word MemManage_Handler
.word BusFault_Handler
.word UsageFault_Handler
.word
0
.word
0
.word
0
.word
0
.word SVC_Handler
.word DebugMon_Handler
.word
0
.word PendSV_Handler
.word SysTick_Handler
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
.word
0
/*******************************************************************************
*
* Provide weak aliases for each Exception handler to the Default_Handler.
* As they are weak aliases, any function with the same name will override
* this definition.
*
*******************************************************************************/
.weak NMI_Handler
.thumb_set NMI_Handler,Default_Handler
.weak HardFault_Handler
.thumb_set HardFault_Handler,Default_Handler
.weak MemManage_Handler
.thumb_set MemManage_Handler,Default_Handler
.weak BusFault_Handler
.thumb_set BusFault_Handler,Default_Handler
.weak UsageFault_Handler
.thumb_set UsageFault_Handler,Default_Handler
.weak SVC_Handler
.thumb_set SVC_Handler,Default_Handler
.weak DebugMon_Handler
.thumb_set DebugMon_Handler,Default_Handler
.weak PendSV_Handler
.thumb_set PendSV_Handler,Default_Handler
.weak SysTick_Handler
.thumb_set SysTick_Handler,Default_Handler
.weak SystemInit
2015-08-10 06:18 AM
You should be able to pull (copy or merge) from one of the other GNU chains supported (Ride/Atollic)
STM32F30x_DSP_StdPeriph_Lib_V1.0.0\Libraries\CMSIS\Device\ST\STM32F30x\Source\Templates\gcc_ride7\startup_stm32f30x.s