UART Hello World example (L152)

Name of the project

l152_uart_hello

Description

The project will sent the “Hello World!” phrase via serial at every 1000 milliseconds at a speed of 19200 bps.

Code snippet (initial code, project structure and VSCode files generated by VPC):

const uint8_t str[] = "Hello World!\r\n"; 
  
int main(void){
  /* local variables */
  
  /* mandatory system initializations */
  vpc_system_init();
  //vpc_rtc_init(); /* enable if required */  
  vpc_gpio_init();
  vpc_usart2_uart_init(); /* enable if required */ 
  /* third-party initializations */
  
  /* do your own initializations below */
  
  while(1){
    /* your forever repeating code */
    uart_putstrF(USART2, str);
    my_delay_ms(1000);
    GPIO_ToggleBits(LD2_GPIO_Port, LD2_Pin);    
    
  }
  return 0;
}

Project published in repository.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.