cancel
Showing results for 
Search instead for 
Did you mean: 

STM32l152 USART configuration

vedhas
Associate II
Posted on December 19, 2012 at 12:47

Hello pals i am new to the stm32 programming, i am trying to configure usart via irq handler, can someone help?

#include <stm32l1xx.h>
#include ''stm32l1xx_usart.h''
#include ''STM32_Init.h''
void
SendByte (
int
byte
);
int
main (
void
)
{
stm32_Init();
return
0;
}
void
USART1_IRQHandler (
void
)
{
volatile unsigned 
int
vsr;
int
ByteSent;
vsr= USART1->SR;
if
(vsr& USART_FLAG_RXNE) 
// did we interrupt on the read
{
// clear the interrupt since we are processing it
USART1->SR &= ~(USART_FLAG_RXNE); 
ByteSent = (USART1->DR & 0x1FF);
SendByte(ByteSent);
}
}
void
SendByte (
int
byte
) 
{
//Wait for the uart to finish sending the byte.
while
(!(USART1->SR & USART_FLAG_TXE));
USART1->DR = (
byte
& 0xFF);
}
STM32_Init.c(32): error: #5: cannot open source input file ''STM32_Reg.h'': No such file or directory

#uar
6 REPLIES 6
Posted on December 19, 2012 at 13:37

Yet you have omitted the initialization code?

If the compiler/IDE isn't finding include files it is indicative that you haven't supplied paths correctly. This is not an unique issue with STM32's or ARM.

Why wouldn't you use the ST firmware library?

Reading the DR will clear the RXNE bit in the SR.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
vedhas
Associate II
Posted on December 20, 2012 at 15:25

hello mate thanks for reply, i have included the init files both in project via keil and also in the project folder, i am new to this programming, ok i will include the stm32 firmware files! 

vedhas
Associate II
Posted on December 21, 2012 at 08:21

mate that was very useful, however i get this message..

main.c(29): error:  #20: identifier ''USART_InitStructure'' is undefined

and i now look in stm32l1xx_usart.h and do not Find USART_InitStructure

will i have to define it explicitly as 

USART_InitTypeDef USART_InitStructure ?

also same message comes up for GPIO

vedhas
Associate II
Posted on December 21, 2012 at 12:20

linking...

.\bin\testux.axf: Error: L6218E: Undefined symbol SystemInit (referred from startup_stm32l1xx_md.o).

.\bin\testux.axf: Error: L6218E: Undefined symbol assert_param (referred from stm32l1xx_gpio.o).

.\bin\testux.axf: Error: L6218E: Undefined symbol RCC_ICSCR_MSIRANGE_0 (referred from stm32l1xx_rcc.o).

.\bin\testux.axf: Error: L6218E: Undefined symbol RCC_ICSCR_MSIRANGE_1 (referred from stm32l1xx_rcc.o).

.\bin\testux.axf: Error: L6218E: Undefined symbol RCC_ICSCR_MSIRANGE_2 (referred from stm32l1xx_rcc.o).

.\bin\testux.axf: Error: L6218E: Undefined symbol RCC_ICSCR_MSIRANGE_3 (referred from stm32l1xx_rcc.o).

.\bin\testux.axf: Error: L6218E: Undefined symbol RCC_ICSCR_MSIRANGE_4 (referred from stm32l1xx_rcc.o).

.\bin\testux.axf: Error: L6218E: Undefined symbol RCC_ICSCR_MSIRANGE_5 (referred from stm32l1xx_rcc.o).

.\bin\testux.axf: Error: L6218E: Undefined symbol RCC_ICSCR_MSIRANGE_6 (referred from stm32l1xx_rcc.o).

Target not created

Posted on December 21, 2012 at 13:59

Your project will need to have ''Include Paths'' point to the assorted directories that contain include files used by the library.

Other include files are typically pulled in via stm32L1xx_conf.h, to define the library structures.

The C side of the startup code is in the system_stm32L1xx.c.

Recommend reviewing, and perhaps cloning, the example project files within the firmware library as a starting point.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..