2010-09-04 10:36 AM
USART doesnot go into interrupt service routine
2011-05-17 05:05 AM
this is init for the LED
/* Configure the GPIO_LED pin */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); ---------------------------- I set up the clocks for USART and GPIO befor init.ing them I didnot see any code in the example for setting the NVIC Vector Table Address ? I simply run below code ----------------------------------------void NVIC_Configuration(void)
{ NVIC_InitTypeDef NVIC_InitStructure; NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);/* Enable the USARTx Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); } what I found strange is how I ''getintvector '' and setintvector'' in STM32 ? just writing this below code is enough ? -------------------------------- void USART1_IRQHandler(void) { if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) { /* Read one byte from the receive data register */ TxBuffer = (USART_ReceiveData(USART1)); GPIOA->ODR ^= GPIO_Pin_1; } if(USART_GetITStatus(USART1, USART_IT_TXE) != RESET) { /* Write one byte to the transmit data register */ USART_SendData(USART1, TxBuffer); } } --------------------- this ISR must echo back the received character but it doesnot this is another clue that it doesnt enter ISR2011-05-17 05:05 AM
>> where might I be wrong ?
We'll it's not clear from your cut-n-paste job, but you certainly need to set up the clocks to USART1 and GPIOA *BEFORE* you program the peripherals. Presumably you're also setting the NVIC Vector Table Address? or perhaps not,. Try looking at the example code ST supplies for exactly this task, ''USART\HyperTerminal_Interrupt'', as least in V2 You're initializing the GPIO pin for the LED somewhere else?2011-05-17 05:05 AM
Hi,
Your code looks more or less ok. Few things I have noticed. I see thatyou have habit of not filling all structure fields I would advise you to do so.
There is no USART enable command (USART_Cmd(USART1,ENABLE)).Interrupt definitions/names are in startup files (.s). Writing properfunction name is enough. Use debugger to check if uC is entering interrupts donot relay on assumptions.
Greetings
Thomas
2011-05-17 05:05 AM
'' There is no USART enable command (USART_Cmd(USART1,ENABLE)). ''
I added this line and it worked thank you very much
2011-05-17 05:05 AM
2011-05-17 05:05 AM
I am struggling to make interrupts work on a STM32L152 on IAR environment.
ST nominally parks the interrupt handlers in stm32f10x_it.c file in their projects. If the handler you want does not exist (ie not instantiated) in the C file, it is weakly defined in the library source, the assembler file is startup\iar\startup_stm32f10x_??.s based on the part family you are using. To make it work you need to put a wrapper/handler in the C file (stm32f10x_it.c, or main.c), and implement to body of the handler.2011-05-17 05:05 AM
2011-05-17 05:05 AM
For TIM4, you should have something like this
NVIC_InitTypeDef NVIC_InitStructure; NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);/* Enable the USARTx Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = TIM4_IRQn; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure);MCU Lüfter,
2011-05-17 05:05 AM
Can you provide a download link, or zip up, the firmware library and example files for the STM32L1xx. Poking around with Google and ST's site haven't yielded what I'm looking for.
Yes, you will have to tailor code to the specific family you are using, most everyone is using the STM32F series, hence the most code/projects are tailored that way. It would probably be easier to use the library than trying to manually program the registers at the bit level.