Stm32f7-Disco Serial transfer data with DMA (Asynchronous)

Stm32f7-Disco Serial transfer data with DMA (Asynchronous) 今回,Stm32f7-Disco Board で,tranfer serial data to PC (Asynchronous 非同期)
1. Clock Setting 
RCC -> High speed clock -> Crystal/Ceramic Resonator
Max speed -> 216 Mhz up

2. Pinout setup
USART6 ->Mode -> Asynchronous 

Without DMA
3. Serial Setting 
Baudrate 11520
Word Length 8bits
4. Source generation and Code edition
In Src/main.c

int main(void)
{

  HAL_Init();
  /* Configure the system clock */
  SystemClock_Config();

 


  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_USART6_UART_Init();

  char buf[20]=”0″;
  int i=0;

  while (1)
  {
    i++;
    sprintf(buf,”Hello world_[%d]n”,i);
    HAL_UART_Transmit(&huart6,buf,sizeof(buf),0x1000);
    HAL_Delay(1000);

  }
}

With DMA
4. Add DMA configuration
Add DMA2 Stream 6
Priority ->High
Mode -> Circle
Data width ->byte

5. Source generation and Code edition 

In Src/main.c

int main(void)
{

  HAL_Init();
  /* Configure the system clock */
  SystemClock_Config();
  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_DMA_Init();
  MX_USART6_UART_Init();
  char buf[20]=”0″;
  int i=0;
  HAL_UART_Transmit_DMA(&huart6, buf, sizeof(buf));

 
  while (1)
  {
    i++;
    sprintf(buf,”Hellotworld_[%d]n”,i);
    HAL_Delay(1000);

  }
}

 

Most views

Leave a Reply

Your email address will not be published. Required fields are marked *