This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to initialize char and int in keil 5

hello! i m using stm32lo73rz in keil micro vresion 5 in hll format.
I cant initialize char and int. I m using unsigned char i[]= "giga" but warning will generate that i not decleared. and when compile the programe in docklight giga will not print correctly any other word will come there at rx side when tx something according to code.this is my email abhij752@gmail.com please help me out from this.

Parents
  • Still a lot of critical code that simply isn't been shown, despite being asked.

    Perhaps try something simple within your grasp, without interrupts or strings

    /* Includes ------------------------------------------------------------------*/
    #include "main.h"
    #include "string.h"
    #include "stdio.h"
    #include "stm32l0xx.h"
    
    /* Private function prototypes -----------------------------------------------*/
    static void LL_Init(void);
    void SystemClock_Config(void);
    static void MX_GPIO_Init(void);
    static void MX_USART2_UART_Init(void);
    /* USER CODE END 0 */
    
    void putstring(char *s)
    {
      while(*s)
      {
        /* Wait for TXE flag to be raised */
        while (!LL_USART_IsActiveFlag_TXE(USART2));
    
        /* Write character in Transmit Data register.
           TXE flag is cleared by writing data in TDR register */
        LL_USART_TransmitData8(USART2, *s++);
      }
    }
    
    int main(void)
    {
      /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
      LL_Init();
    
      /* Configure the system clock */
      SystemClock_Config();
    
      MX_GPIO_Init();
      MX_USART2_UART_Init(); // code not shown, don't enable interrupts
    
      putstring("Hello World!\n");
    
      while(1)
      {
        if (LL_USART_IsActiveFlag_RXNE(USART2)) /* character ready */
        {
          uint8_t ch = LL_USART_ReceiveData8(USART2); /* read it */
    
          /* Wait for TXE flag to be raised */
          while (!LL_USART_IsActiveFlag_TXE(USART2));
    
          /* Write character in Transmit Data register.
             TXE flag is cleared by writing data in TDR register */
          LL_USART_TransmitData8(USART2, ch);
        }
    
        if (LL_USART_IsActiveFlag_NE(USART2)
          LL_USART_ClearFlag_NE(USART2);
    
        if (LL_USART_IsActiveFlag_FE(USART2)
          LL_USART_ClearFlag_FE(USART2);
    
        if (LL_USART_IsActiveFlag_PE(USART2)
          LL_USART_ClearFlag_PE(USART2);
      }
    }
    

Reply
  • Still a lot of critical code that simply isn't been shown, despite being asked.

    Perhaps try something simple within your grasp, without interrupts or strings

    /* Includes ------------------------------------------------------------------*/
    #include "main.h"
    #include "string.h"
    #include "stdio.h"
    #include "stm32l0xx.h"
    
    /* Private function prototypes -----------------------------------------------*/
    static void LL_Init(void);
    void SystemClock_Config(void);
    static void MX_GPIO_Init(void);
    static void MX_USART2_UART_Init(void);
    /* USER CODE END 0 */
    
    void putstring(char *s)
    {
      while(*s)
      {
        /* Wait for TXE flag to be raised */
        while (!LL_USART_IsActiveFlag_TXE(USART2));
    
        /* Write character in Transmit Data register.
           TXE flag is cleared by writing data in TDR register */
        LL_USART_TransmitData8(USART2, *s++);
      }
    }
    
    int main(void)
    {
      /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
      LL_Init();
    
      /* Configure the system clock */
      SystemClock_Config();
    
      MX_GPIO_Init();
      MX_USART2_UART_Init(); // code not shown, don't enable interrupts
    
      putstring("Hello World!\n");
    
      while(1)
      {
        if (LL_USART_IsActiveFlag_RXNE(USART2)) /* character ready */
        {
          uint8_t ch = LL_USART_ReceiveData8(USART2); /* read it */
    
          /* Wait for TXE flag to be raised */
          while (!LL_USART_IsActiveFlag_TXE(USART2));
    
          /* Write character in Transmit Data register.
             TXE flag is cleared by writing data in TDR register */
          LL_USART_TransmitData8(USART2, ch);
        }
    
        if (LL_USART_IsActiveFlag_NE(USART2)
          LL_USART_ClearFlag_NE(USART2);
    
        if (LL_USART_IsActiveFlag_FE(USART2)
          LL_USART_ClearFlag_FE(USART2);
    
        if (LL_USART_IsActiveFlag_PE(USART2)
          LL_USART_ClearFlag_PE(USART2);
      }
    }
    

Children