2012-12-19 03:47 AM
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
2012-12-19 04:37 AM
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.2012-12-20 06:25 AM
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!
2012-12-20 07:58 AM
Here was an example using the library on the STM32L, USART3 with 8-bit odd parity.
2012-12-20 11:21 PM
mate that was very useful, however i get this message..
main.c(29): error: #20: identifier ''USART_InitStructure'' is undefinedand i now look in stm32l1xx_usart.h and do not Find USART_InitStructurewill i have to define it explicitly as USART_InitTypeDef USART_InitStructure ?also same message comes up for GPIO2012-12-21 03:20 AM
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 created2012-12-21 04:59 AM
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.