Stm32f7 - Disco Serial receive data

0 nhận xét

Summary:

今回, PCからgenerated serial data を Stm32f7 Disco boardで receive and display on LCD screen.
1. Clock Setting
RCC -> High speed clock -> Crystal Ceramic resonator
System clock ->216 Mhz up.
2. Pinout Setting
USART6 ->Mode ->Asynchronous
( Without DMA)
3. USART Setting
Baudrate :11520
Word length : 8bits
NVIC : USART6 Global interrupt Enable check.
4. Source generation and edition

#include "stm32f7xx_hal.h"
#include "stm32f7xx_hal.h"
#include "stm32f7xx_hal_uart.h"
#include "stm32f7xx_hal_sdram.h"
#include "stm32f7xx_hal_ltdc.h"
#include "stm32746g_discovery.h"
#include "stm32746g_discovery_lcd.h"
#include "stm32746g_discovery_sdram.h"
#include "stm32f7xx_ll_fmc.h"


------------------------------------------------------------------

 BSP_LCD_LayerDefaultInit(0, LCD_FB_START_ADDRESS);
 BSP_LCD_LayerDefaultInit(1, LCD_FB_START_ADDRESS+(BSP_LCD_GetXSize()*BSP_LCD_GetYSize()*4));
 
 BSP_LCD_DisplayOn();
 BSP_LCD_SelectLayer(0);
 BSP_LCD_Clear(LCD_COLOR_BLACK);
 BSP_LCD_SelectLayer(1);
 BSP_LCD_Clear(LCD_COLOR_BLACK);
 BSP_LCD_SetFont(&LCD_DEFAULT_FONT);
 BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
 BSP_LCD_SetTextColor(LCD_COLOR_DARKBLUE);
 char buf[16];
 char string[10]="Receive :";
 HAL_UART_Receive_IT(&huart6, buf, 16);

  while (1)
  {
     BSP_LCD_Clear(LCD_COLOR_WHITE);
     BSP_LCD_DisplayStringAt(0, LINE(3), (uint8_t *)string, CENTER_MODE);
     BSP_LCD_DisplayStringAt(0, LINE(4), (uint8_t *)buf, CENTER_MODE);
     HAL_Delay(100);

  }
}

-------------------------------------------------------------------------------

(With DMA)
3. USART Setting
Baudrate :11520
Word length : 8bits
USART6_Rx DMA2 Stream1 ->add
Priority ->High
Mode : Circle

 4. Source generation and edition

#include "stm32f7xx_hal.h"
#include "stm32f7xx_hal.h"
#include "stm32f7xx_hal_uart.h"
#include "stm32f7xx_hal_sdram.h"
#include "stm32f7xx_hal_ltdc.h"
#include "stm32746g_discovery.h"
#include "stm32746g_discovery_lcd.h"
#include "stm32746g_discovery_sdram.h"
#include "stm32f7xx_ll_fmc.h"


------------------------------------------------------------------

 BSP_LCD_LayerDefaultInit(0, LCD_FB_START_ADDRESS);
 BSP_LCD_LayerDefaultInit(1, LCD_FB_START_ADDRESS+(BSP_LCD_GetXSize()*BSP_LCD_GetYSize()*4));
 
 BSP_LCD_DisplayOn();
 BSP_LCD_SelectLayer(0);
 BSP_LCD_Clear(LCD_COLOR_BLACK);
 BSP_LCD_SelectLayer(1);
 BSP_LCD_Clear(LCD_COLOR_BLACK);
 BSP_LCD_SetFont(&LCD_DEFAULT_FONT);
 BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
 BSP_LCD_SetTextColor(LCD_COLOR_DARKBLUE);
 char buf[16];
 char string[10]="Receive :";
HAL_UART_Receive_DMA(&huart6, buf, 16);

  while (1)
  {
     BSP_LCD_Clear(LCD_COLOR_WHITE);
     BSP_LCD_DisplayStringAt(0, LINE(3), (uint8_t *)string, CENTER_MODE);
     BSP_LCD_DisplayStringAt(0, LINE(4), (uint8_t *)buf, CENTER_MODE);
     HAL_Delay(100);

  }
}

Facebook Comments
Blogger Comments
Share knowledge

Copyright © 2016 - Share knowledge ®