2010-09-29 08:20 PM
writing data to USART1 of STM8L152
2011-05-17 06:10 AM
Hi ANN,
When you write data in USART1_DR it is sent and you can't read it back from USART1_DR.USART1_DR is for both writing data to be sent and reading received data. If you want to make a test, you can connect Tx to Rx and you will read back your data. That is my own understanding, perhaps ST people can confirm this. regards, MCU Lüfter2011-05-17 06:10 AM
Hi.
I have this, from STM sample library, maybe it can help /*deinitilize systme remap*/ SYSCFG_REMAPDeInit(); /* Change RX-TX default map to A2-A3*/ SYSCFG_REMAPPinConfig(((uint16_t)0x011C),ENABLE); /*Enable Usart clock */ CLK_PeripheralClockConfig(CLK_Peripheral_USART1, ENABLE); /*Set the USART RX and USART TX at high level*/ GPIO_ExternalPullUpConfig(GPIOA, GPIO_Pin_2 , ENABLE); GPIO_Init(GPIOA, GPIO_Pin_3, GPIO_Mode_In_PU_IT); /* USART configuration ------------------------------------------------------*/ /* USART configured as follow: - BaudRate = 115200 baud - Word Length = 8 Bits - One Stop Bit - No parity - Receive and transmit enabled */ USART_Init(USART1, (uint32_t)19200, USART_WordLength_8b, USART_StopBits_1, USART_Parity_No, (USART_Mode_TypeDef)(USART_Mode_Rx | USART_Mode_Tx)); USART_SendData8(USART1,0x58);2011-05-17 06:10 AM
Hi leo,
ANN is making doing an interesting job. He is using his own code and he doesn't like to use ST one (as I am doing now). Good idea but that could be time consuming job. MCU Lüfter2011-05-17 06:10 AM
2011-05-17 06:10 AM
Hello Leo and lowpowerMCU,
Thanks for your replies. Problem has been solved now. What I want is not to build up my own lib. I just want to understand the functionality of STM8L. A learning process. Rather than using provided examples coding of my own makes the thing more understandable and controlable. Thanks :p