久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 12602|回復(fù): 14
收起左側(cè)

STM32F030C8T6串口例程

  [復(fù)制鏈接]
ID:254507 發(fā)表于 2017-11-28 09:44 | 顯示全部樓層 |閱讀模式
    現(xiàn)在提供STM32F030C8T6串口例程,適合初學(xué)上手
單片機源程序如下:
  1. /**
  2.   ******************************************************************************
  3.   * @file    USART/USART_Printf/main.c
  4.   * @author  MCD Application Team
  5.   * @version V1.4.0
  6.   * @date    24-July-2014
  7.   * @brief   Main program body
  8.   ******************************************************************************
  9.   * @attention
  10.   *
  11.   * <h2><center>© COPYRIGHT 2014 STMicroelectronics</center></h2>
  12.   *
  13.   * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  14.   * You may not use this file except in compliance with the License.
  15.   * You may obtain a copy of the License at:
  16.   *
  17.   *        http://www.st.com/software_license_agreement_liberty_v2
  18.   *
  19.   * Unless required by applicable law or agreed to in writing, software
  20.   * distributed under the License is distributed on an "AS IS" BASIS,
  21.   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22.   * See the License for the specific language governing permissions and
  23.   * limitations under the License.
  24.   *
  25.   ******************************************************************************
  26.   */

  27. /* Includes ------------------------------------------------------------------*/
  28. #include "main.h"

  29. /** @addtogroup STM32F0xx_StdPeriph_Examples
  30.   * @{
  31.   */

  32. /** @addtogroup USART_Printf
  33.   * @{
  34.   */

  35. /* Private typedef -----------------------------------------------------------*/
  36. /* Private define ------------------------------------------------------------*/
  37. /* Private macro -------------------------------------------------------------*/
  38. /* Private variables ---------------------------------------------------------*/
  39. /* Private function prototypes -----------------------------------------------*/
  40. void USART_Config(void);


  41.   // 重定義  
  42. int fputc(int ch, FILE *f)
  43. {
  44.         while (!(USART1->ISR & USART_FLAG_TXE));
  45.         USART1->TDR = ch;
  46.   
  47.   return (ch);
  48. }

  49. void USART1_Send_Char(unsigned char c)
  50. {
  51.         while(!((USART1->ISR)&USART_FLAG_TXE));
  52.         USART1->TDR=c;       
  53. }
  54. void USART1_Send_String(char *s )
  55. {
  56.         while (*s)
  57.         USART1_Send_Char(*s++);
  58. }

  59. void SYSTICK_INIT(void)
  60. {
  61.                 SysTick_Config(SystemCoreClock / 1000);        //Set SysTick Timer for 1ms interrupts
  62.                 //SysTick_Config(SystemCoreClock / 200);        //Set SysTick Timer for 5ms interrupts
  63.                 //SysTick_Config(SystemCoreClock / 100);        //Set SysTick Timer for 10ms interrupts
  64.                 //SysTick_Config(SystemCoreClock / 10);        //Set SysTick Timer for 100ms interrupts     
  65. }


  66. /**
  67.   * @brief  Main program
  68.   * @param  None
  69.   * @retval None
  70.   */
  71. int main(void)
  72. {
  73.   /*!< At this stage the microcontroller clock setting is already configured,
  74.        this is done through SystemInit() function which is called from startup
  75.        file (startup_stm32f0xx.s) before to branch to application main.
  76.        To reconfigure the default setting of SystemInit() function, refer to
  77.        system_stm32f0xx.c file
  78.      */     
  79.        
  80.         //        SYSTICK_INIT();
  81.                

  82.                 /* USART configuration */  
  83.                 USART_Config();
  84.                 USART1_Send_String("Fresh Persimmon all right reserved!\r\n");
  85.                 printf("USART Printf Example: retarget the C library printf function to the USART\r\n");

  86.           printf("ASD=%.3f\r\n",9.88987);
  87.                
  88.                 while (1)
  89.                 {
  90.                        
  91.                 }
  92. }

  93. /**
  94.   * @brief Configure the USART Device
  95.   * @param  None
  96.   * @retval None
  97.   */
  98. void USART_Config(void)
  99. {
  100.     GPIO_InitTypeDef GPIO_InitStructure;  
  101.                 USART_InitTypeDef USART_InitStructure;
  102.                 NVIC_InitTypeDef         NVIC_InitStructure;
  103.        
  104.                 NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
  105.                 NVIC_InitStructure.NVIC_IRQChannelPriority = 2;
  106.                 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  107.                 NVIC_Init(&NVIC_InitStructure);
  108.        
  109.                 RCC_AHBPeriphClockCmd( RCC_AHBPeriph_GPIOA, ENABLE);
  110.                 RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE );                                               
  111.                 GPIO_PinAFConfig(GPIOA,GPIO_PinSource9,GPIO_AF_1);
  112.                 GPIO_PinAFConfig(GPIOA,GPIO_PinSource10,GPIO_AF_1);                                                                                              
  113.                 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9|GPIO_Pin_10;                 
  114.                 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  115.                 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  116.                 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
  117.                 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  118.                 GPIO_Init(GPIOA, &GPIO_InitStructure);   

  119.                 USART_InitStructure.USART_BaudRate = 115200;
  120.                 USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  121.                 USART_InitStructure.USART_StopBits = USART_StopBits_1;
  122.                 USART_InitStructure.USART_Parity = USART_Parity_No;
  123.                 USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
  124.                 USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
  125.                 USART_Init(USART1, &USART_InitStructure);
  126.                
  127.                 USART_Cmd(USART1, ENABLE);
  128.                 USART_ITConfig(USART1,USART_IT_RXNE,ENABLE);
  129.   

  130. }


  131. #ifdef  USE_FULL_ASSERT

  132. /**
  133.   * @brief  Reports the name of the source file and the source line number
  134. ……………………

  135. …………限于本文篇幅 余下代碼請從51黑下載附件…………
復(fù)制代碼

所有資料51hei提供下載:
STM32F030C8T6串口例程.zip (487.8 KB, 下載次數(shù): 549)

評分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎勵!

查看全部評分

回復(fù)

使用道具 舉報

ID:368498 發(fā)表于 2018-7-10 10:33 | 顯示全部樓層
感謝分享。。!
回復(fù)

使用道具 舉報

ID:369278 發(fā)表于 2018-7-19 15:48 | 顯示全部樓層
下載了,不錯,謝謝!
回復(fù)

使用道具 舉報

ID:388109 發(fā)表于 2018-10-17 18:21 | 顯示全部樓層
下載,好東西
回復(fù)

使用道具 舉報

ID:380361 發(fā)表于 2019-9-26 14:54 | 顯示全部樓層

感謝分享!。。
回復(fù)

使用道具 舉報

ID:616902 發(fā)表于 2019-9-26 21:15 | 顯示全部樓層
正在找這個呢
回復(fù)

使用道具 舉報

ID:185372 發(fā)表于 2019-9-27 08:23 | 顯示全部樓層
這個可以有,不過想屏蔽一下串口呢。
回復(fù)

使用道具 舉報

ID:622200 發(fā)表于 2019-10-11 11:28 | 顯示全部樓層
有空下來看看
回復(fù)

使用道具 舉報

ID:21828 發(fā)表于 2019-12-30 10:02 | 顯示全部樓層
感謝分享。。。
回復(fù)

使用道具 舉報

ID:61493 發(fā)表于 2019-12-30 15:33 | 顯示全部樓層
謝謝分享,不錯的東西
回復(fù)

使用道具 舉報

ID:469589 發(fā)表于 2020-1-19 11:52 | 顯示全部樓層
感謝分享,學(xué)習(xí)了!
回復(fù)

使用道具 舉報

ID:568247 發(fā)表于 2021-6-10 17:38 | 顯示全部樓層
感謝樓主的分享,部分疑惑解答了
回復(fù)

使用道具 舉報

ID:1029891 發(fā)表于 2022-5-30 15:47 | 顯示全部樓層
好用嗎?
回復(fù)

使用道具 舉報

ID:1031499 發(fā)表于 2022-6-1 12:03 | 顯示全部樓層
贊,正在找串口程序。
回復(fù)

使用道具 舉報

ID:1060439 發(fā)表于 2023-1-6 13:38 | 顯示全部樓層
剛下載了,不錯,正在學(xué)習(xí)中
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 亚洲精品一区二 | 天堂资源 | 国产成人精品一区二区三区四区 | 91视频观看 | www.日韩 | 亚洲天堂精品久久 | 国产日韩欧美另类 | 成人激情视频免费在线观看 | 青青久久 | 欧美一区 | 亚洲国产精品视频一区 | 成人精品鲁一区一区二区 | 一区二区三区在线免费观看视频 | 精品成人一区二区 | 91视频官网 | www.99re| 精品中文字幕一区 | 久久精品二区 | 日韩三级精品 | 亚洲一区国产精品 | 欧美一级大片免费观看 | 中文字幕综合 | 免费在线一区二区 | 久久亚洲国产精品日日av夜夜 | 国产一区二区中文字幕 | 亚洲h在线观看 | av天天干| 欧美成人精品 | 国产精品成人一区二区 | 日韩av一区二区在线观看 | 亚洲1区 | 一级黄色短片 | 国产91久久久久久 | 久久99精品久久久久久国产越南 | 久久久久久国产精品 | 日本一级淫片免费啪啪3 | 亚洲精品永久免费 | av手机在线播放 | 亚洲精品久久久久久久不卡四虎 | 日本成人片在线观看 | 精品亚洲永久免费精品 |