Skip to main content
nanayakkaraan
Associate III
September 30, 2010
Question

writing data to USART1 of STM8L152

  • September 30, 2010
  • 5 replies
  • 1651 views
Posted on September 30, 2010 at 05:20

writing data to USART1 of STM8L152

    This topic has been closed for replies.

    5 replies

    lowpowermcu
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 15:10

    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üfter

    leoren_tm
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 15:10

    Hi.

       Yah it is. but time, time time............. :D

    anyway, ST library is open, soo she can directly point it to library to get the real code, as datasheet is really not that complete, and which i think ST provided(the lib) to fill that ''not complete'' part.

        Also, as ST said, there library set-up is compatible/almost same to there ST32, planning to jump on ST32 would be easy.

     

        So your planning to make your library? :)

    Have a nice-fun Coding Lüfter and ANN

    lowpowermcu
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 15:10

    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üfter

    leoren_tm
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 15:10

    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);

    nanayakkaraan
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 15:10

    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