FMUSER Wirless Transmit Video And Audio More Easier !

[email protected] WhatsApp +8618078869184
Language

    STM325 serial port configuration function STM32 serial port How to send data

     

    "Configuration function and transceiver data function code of 5 serial ports: #include “stm32f10x.h” #include “misc.h” #include “stm32f10x_ gpio.h” #include “stm32f10x_ usart.h” void USART1_ Configuration(void) { GPIO_ InitTypeDef GPIO_ InitStructure; USART_ InitTypeDef USART_ InitStructure; NVIC_ InitTypeDef NVIC_ InitStructure; RCC_ APB2PeriphClockCmd(RCC_ APB2Periph_ GPIOA, ENABLE ); RCC_ APB2PeriphClockCmd(RCC_ APB2Periph_ USART1, ENABLE ); GPIO_ InitStructure.GPIO_ Pin = GPIO_ Pin_ 9; // USART1 TX; GPIO_ InitStructure.GPIO_ Mode = GPIO_ Mode_ AF_ PP; // Multiplex push-pull output; GPIO_ InitStructure.GPIO_ Speed = GPIO_ Speed_ 50MHz; GPIO_ Init(GPIOA, &GPIO_ InitStructure); // Port a; GPIO_ InitStructure.GPIO_ Pin = GPIO_ Pin_ 10; // USART1 RX; GPIO_ InitStructure.GPIO_ Mode = GPIO_ Mode_ IN_ FLOATING; // Floating input; GPIO_ Init(GPIOA, &GPIO_ InitStructure); // Port a; USART_ InitStructure.USART_ BaudRate = 9600; // Baud rate; USART_ InitStructure.USART_ WordLength = USART_ WordLength_ 8b; // 8 data bits; USART_ InitStructure.USART_ StopBits = USART_ StopBits_ 1; // Stop bit: 1 bit; USART_ InitStructure.USART_ Parity = USART_ Parity_ No ; // No check bit; USART_ InitStructure.USART_ HardwareFlowControl = USART_ HardwareFlowControl_ None; //No hardware flow control; USART_ InitStructure.USART_ Mode = USART_ Mode_ Rx | USART_ Mode_ Tx; //Transceiver mode; USART_ Init(USART1, &USART_ InitStructure);// Configure serial port parameters; NVIC_ PriorityGroupConfig(NVIC_ PriorityGroup_ 2); // Set interrupt group, 4-bit preemption priority and 4-bit response priority; NVIC_ InitStructure.NVIC_ IRQChannel = USART1_ IRQn; // Interrupt number; NVIC_ InitStructure.NVIC_ IRQChannelPreemptionPriority = 0; // Preemptive priority; NVIC_ InitStructure.NVIC_ IRQChannelSubPriority = 0; // Response priority; NVIC_ InitStructure.NVIC_ IRQChannelCmd = ENABLE; NVIC_ Init(&NVIC_ InitStructure); USART_ ITConfig(USART1, USART_ IT_ RXNE, ENABLE); USART_ Cmd(USART1, ENABLE); // Enable serial port; } void USART1_ Send_ Byte (U8 data) / / send a byte; { USART_ SendData(USART1,Data); while( USART_ GetFlagStatus(USART1, USART_ FLAG_ TC) == RESET ); } void USART1_ Send_ String (U8 * data) / / send string; { while(*Data) USART1_ Send_ Byte(*Data++); } void USART1_ Irqhandler (void) / / interrupt processing function; { u8 res; if(USART_ GetITStatus(USART1, USART_ IT_ Rxne) = = set) / / judge whether an interrupt occurs; { USART_ ClearFlag(USART1, USART_ IT_ RXNE); // Clear the flag bit; res=USART_ ReceiveData(USART1); // Receiving data; USART1_ Send_ Byte(res); // User defined; } } void USART2_ Configuration(void) { GPIO_ InitTypeDef GPIO_ InitStructure; USART_ InitTypeDef USART_ InitStructure; NVIC_ InitTypeDef NVIC_ InitStructure; RCC_ APB2PeriphClockCmd(RCC_ APB2Periph_ GPIOA, ENABLE ); RCC_ APB1PeriphClockCmd(RCC_ APB1Periph_ USART2, ENABLE ); GPIO_ InitStructure.GPIO_ Pin = GPIO_ Pin_ 2; // USART2 TX; GPIO_ InitStructure.GPIO_ Mode = GPIO_ Mode_ AF_ PP; // Multiplex push-pull output; GPIO_ InitStructure.GPIO_ Speed = GPIO_ Speed_ 50MHz; GPIO_ Init(GPIOA, &GPIO_ InitStructure); // Port a; GPIO_ InitStructure.GPIO_ Pin = GPIO_ Pin_ 3; // USART2 RX; GPIO_ InitStructure.GPIO_ Mode = GPIO_ Mode_ IN_ FLOATING; // Floating input; GPIO_ Init(GPIOA, &GPIO_ InitStructure); // Port a; USART_ InitStructure.USART_ BaudRate = 9600; // Baud rate; USART_ InitStructure.USART_ WordLength = USART_ WordLength_ 8b; // 8 data bits; USART_ InitStructure.USART_ StopBits = USART_ StopBits_ 1; // Stop bit: 1 bit; USART_ InitStructure.USART_ Parity = USART_ Parity_ No ; // No check bit; USART_ InitStructure.USART_ HardwareFlowControl = USART_ HardwareFlowControl_ None; //No hardware flow control; USART_ InitStructure.USART_ Mode = USART_ Mode_ Rx | USART_ Mode_ Tx; //Transceiver mode; USART_ Init(USART2, &USART_ InitStructure);// Configure serial port parameters; NVIC_ PriorityGroupConfig(NVIC_ PriorityGroup_ 2); // Set interrupt group, 4-bit preemption priority and 4-bit response priority; NVIC_ InitStructure.NVIC_ IRQChannel = USART2_ IRQn; // Interrupt number; NVIC_ InitStructure.NVIC_ IRQChannelPreemptionPriority = 0; // Preemptive priority; NVIC_ InitStructure.NVIC_ IRQChannelSubPriority = 0; // Response priority; NVIC_ InitStructure.NVIC_ IRQChannelCmd = ENABLE; NVIC_ Init(&NVIC_ InitStructure); USART_ ITConfig(USART2, USART_ IT_ RXNE, ENABLE); USART_ Cmd(USART2, ENABLE); // Enable serial port; } void USART2_ Send_ Byte (U8 data) / / send a byte; { USART_ SendData(USART2,Data); while( USART_ GetFlagStatus(USART2, USART_ FLAG_ TC) == RESET ); } void USART2_ Send_ String (U8 * data) / / send string; { while(*Data) USART2_ Send_ Byte(*Data++); } void USART2_ Irqhandler (void) / / interrupt processing function; { u8 res; if(USART_ GetITStatus(USART2, USART_ IT_ Rxne) = = set) / / judge whether an interrupt occurs; { USART_ ClearFlag(USART2, USART_ IT_ RXNE); // Clear the flag bit; res=USART_ ReceiveData(USART2); // Receiving data; USART2_ Send_ Byte(res); // User defined; } } void USART3_ Configuration(void) { GPIO_ InitTypeDef GPIO_ InitStructure; USART_ InitTypeDef USART_ InitStructure; NVIC_ InitTypeDef NVIC_ InitStructure; RCC_ APB2PeriphClockCmd(RCC_ APB2Periph_ GPIOB, ENABLE ); RCC_ APB1PeriphClockCmd(RCC_ APB1Periph_ USART3, ENABLE ); GPIO_ InitStructure.GPIO_ Pin = GPIO_ Pin_ 10; // USART3 TX; GPIO_ InitStructure.GPIO_ Mode = GPIO_ Mode_ AF_ PP; // Multiplex push-pull output; GPIO_ InitStructure.GPIO_ Speed = GPIO_ Speed_ 50MHz; GPIO_ Init(GPIOB, &GPIO_ InitStructure); // Port B; GPIO_ InitStructure.GPIO_ Pin = GPIO_ Pin_ 11; // USART3 RX; GPIO_ InitStructure.GPIO_ Mode = GPIO_ Mode_ IN_ FLOATING; // Floating input; GPIO_ Init(GPIOB, &GPIO_ InitStructure); // Port B; USART_ InitStructure.USART_ BaudRate = 9600; // Baud rate; USART_ InitSt

     

     

     

     

    List all Question

    Nickname

    Email

    Questions

    Our other product:

    Professional FM Radio Station Equipment Package

     



     

    Hotel IPTV Solution

     


      Enter email  to get a surprise

      fmuser.org

      es.fmuser.org
      it.fmuser.org
      fr.fmuser.org
      de.fmuser.org
      af.fmuser.org ->Afrikaans
      sq.fmuser.org ->Albanian
      ar.fmuser.org ->Arabic
      hy.fmuser.org ->Armenian
      az.fmuser.org ->Azerbaijani
      eu.fmuser.org ->Basque
      be.fmuser.org ->Belarusian
      bg.fmuser.org ->Bulgarian
      ca.fmuser.org ->Catalan
      zh-CN.fmuser.org ->Chinese (Simplified)
      zh-TW.fmuser.org ->Chinese (Traditional)
      hr.fmuser.org ->Croatian
      cs.fmuser.org ->Czech
      da.fmuser.org ->Danish
      nl.fmuser.org ->Dutch
      et.fmuser.org ->Estonian
      tl.fmuser.org ->Filipino
      fi.fmuser.org ->Finnish
      fr.fmuser.org ->French
      gl.fmuser.org ->Galician
      ka.fmuser.org ->Georgian
      de.fmuser.org ->German
      el.fmuser.org ->Greek
      ht.fmuser.org ->Haitian Creole
      iw.fmuser.org ->Hebrew
      hi.fmuser.org ->Hindi
      hu.fmuser.org ->Hungarian
      is.fmuser.org ->Icelandic
      id.fmuser.org ->Indonesian
      ga.fmuser.org ->Irish
      it.fmuser.org ->Italian
      ja.fmuser.org ->Japanese
      ko.fmuser.org ->Korean
      lv.fmuser.org ->Latvian
      lt.fmuser.org ->Lithuanian
      mk.fmuser.org ->Macedonian
      ms.fmuser.org ->Malay
      mt.fmuser.org ->Maltese
      no.fmuser.org ->Norwegian
      fa.fmuser.org ->Persian
      pl.fmuser.org ->Polish
      pt.fmuser.org ->Portuguese
      ro.fmuser.org ->Romanian
      ru.fmuser.org ->Russian
      sr.fmuser.org ->Serbian
      sk.fmuser.org ->Slovak
      sl.fmuser.org ->Slovenian
      es.fmuser.org ->Spanish
      sw.fmuser.org ->Swahili
      sv.fmuser.org ->Swedish
      th.fmuser.org ->Thai
      tr.fmuser.org ->Turkish
      uk.fmuser.org ->Ukrainian
      ur.fmuser.org ->Urdu
      vi.fmuser.org ->Vietnamese
      cy.fmuser.org ->Welsh
      yi.fmuser.org ->Yiddish

       
  •  

    FMUSER Wirless Transmit Video And Audio More Easier !

  • Contact

    Address:
    No.305 Room HuiLan Building No.273 Huanpu Road Guangzhou China 510620

    E-mail:
    [email protected]

    Tel / WhatApps:
    +8618078869184

  • Categories

  • Newsletter

    FIRST OR FULL NAME

    E-mail

  • paypal solution  Western UnionBank OF China
    E-mail:[email protected]   WhatsApp:+8618078869184   Skype:sky198710021 Chat with me
    Copyright 2006-2020 Powered By www.fmuser.org

    Contact Us