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

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

搜索
查看: 12655|回復(fù): 14
打印 上一主題 下一主題
收起左側(cè)

STM32F030C8T6串口例程

  [復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:254507 發(fā)表于 2017-11-28 09:44 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
    現(xiàn)在提供STM32F030C8T6串口例程,適合初學(xué)上手
單片機(jī)源程序如下:
  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. …………限于本文篇幅 余下代碼請(qǐng)從51黑下載附件…………
復(fù)制代碼

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


評(píng)分

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

查看全部評(píng)分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏3 分享淘帖 頂2 踩
回復(fù)

使用道具 舉報(bào)

沙發(fā)
ID:368498 發(fā)表于 2018-7-10 10:33 | 只看該作者
感謝分享!!!!
回復(fù)

使用道具 舉報(bào)

板凳
ID:369278 發(fā)表于 2018-7-19 15:48 | 只看該作者
下載了,不錯(cuò),謝謝!!
回復(fù)

使用道具 舉報(bào)

地板
ID:388109 發(fā)表于 2018-10-17 18:21 | 只看該作者
下載,好東西
回復(fù)

使用道具 舉報(bào)

5#
ID:380361 發(fā)表于 2019-9-26 14:54 | 只看該作者

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

使用道具 舉報(bào)

6#
ID:616902 發(fā)表于 2019-9-26 21:15 | 只看該作者
正在找這個(gè)呢
回復(fù)

使用道具 舉報(bào)

7#
ID:185372 發(fā)表于 2019-9-27 08:23 | 只看該作者
這個(gè)可以有,不過(guò)想屏蔽一下串口呢。
回復(fù)

使用道具 舉報(bào)

8#
ID:622200 發(fā)表于 2019-10-11 11:28 | 只看該作者
有空下來(lái)看看
回復(fù)

使用道具 舉報(bào)

9#
ID:21828 發(fā)表于 2019-12-30 10:02 | 只看該作者
感謝分享!!!!
回復(fù)

使用道具 舉報(bào)

10#
ID:61493 發(fā)表于 2019-12-30 15:33 | 只看該作者
謝謝分享,不錯(cuò)的東西
回復(fù)

使用道具 舉報(bào)

11#
ID:469589 發(fā)表于 2020-1-19 11:52 | 只看該作者
感謝分享,學(xué)習(xí)了!
回復(fù)

使用道具 舉報(bào)

12#
ID:568247 發(fā)表于 2021-6-10 17:38 | 只看該作者
感謝樓主的分享,部分疑惑解答了
回復(fù)

使用道具 舉報(bào)

13#
ID:1029891 發(fā)表于 2022-5-30 15:47 | 只看該作者
好用嗎?
回復(fù)

使用道具 舉報(bào)

14#
ID:1031499 發(fā)表于 2022-6-1 12:03 | 只看該作者
贊,正在找串口程序。
回復(fù)

使用道具 舉報(bào)

15#
ID:1060439 發(fā)表于 2023-1-6 13:38 | 只看該作者
剛下載了,不錯(cuò),正在學(xué)習(xí)中
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

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

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

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 国产精品高潮呻吟久久aⅴ码 | 久久国产福利 | 综合网中文字幕 | 2020亚洲天堂 | 一区二区三区四区不卡视频 | 国产馆 | 天天综合91 | 午夜久久久 | 国产精品欧美日韩 | 精品亚洲一区二区三区四区五区 | 欧美影院久久 | 久久9视频| 婷婷国产一区 | av网址在线播放 | 一区二区三区免费观看 | 欧美午夜一区二区三区免费大片 | 国产精品视屏 | 九九精品在线 | 蜜桃免费av | 噜噜噜噜狠狠狠7777视频 | 麻豆久久久久 | 国内自拍视频在线观看 | 国产成人精品区一区二区不卡 | 国产精品久久久久久久 | 日韩小视频在线 | 国产精品观看 | 天堂亚洲网 | 成人乱人乱一区二区三区软件 | 欧美日韩亚洲视频 | 日韩一区在线播放 | 99精品免费在线观看 | 国产美女在线免费观看 | 欧美一级高清片 | 一区二区视频在线 | 日本a v在线播放 | 日本黄色免费大片 | 18成人在线观看 | 91视频.| 在线播放中文字幕 | 欧美激情va永久在线播放 | av大全在线 |