久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费
標題:
STM32F030C8T6串口例程
[打印本頁]
作者:
liweijin66
時間:
2017-11-28 09:44
標題:
STM32F030C8T6串口例程
現在提供STM32F030C8T6串口例程,適合初學上手
單片機源程序如下:
/**
******************************************************************************
* @file USART/USART_Printf/main.c
* @author MCD Application Team
* @version V1.4.0
* @date 24-July-2014
* @brief Main program body
******************************************************************************
* @attention
*
* <h2><center>© COPYRIGHT 2014 STMicroelectronics</center></h2>
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/** @addtogroup STM32F0xx_StdPeriph_Examples
* @{
*/
/** @addtogroup USART_Printf
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
void USART_Config(void);
// 重定義
int fputc(int ch, FILE *f)
{
while (!(USART1->ISR & USART_FLAG_TXE));
USART1->TDR = ch;
return (ch);
}
void USART1_Send_Char(unsigned char c)
{
while(!((USART1->ISR)&USART_FLAG_TXE));
USART1->TDR=c;
}
void USART1_Send_String(char *s )
{
while (*s)
USART1_Send_Char(*s++);
}
void SYSTICK_INIT(void)
{
SysTick_Config(SystemCoreClock / 1000); //Set SysTick Timer for 1ms interrupts
//SysTick_Config(SystemCoreClock / 200); //Set SysTick Timer for 5ms interrupts
//SysTick_Config(SystemCoreClock / 100); //Set SysTick Timer for 10ms interrupts
//SysTick_Config(SystemCoreClock / 10); //Set SysTick Timer for 100ms interrupts
}
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32f0xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32f0xx.c file
*/
// SYSTICK_INIT();
/* USART configuration */
USART_Config();
USART1_Send_String("Fresh Persimmon all right reserved!\r\n");
printf("USART Printf Example: retarget the C library printf function to the USART\r\n");
printf("ASD=%.3f\r\n",9.88987);
while (1)
{
}
}
/**
* @brief Configure the USART Device
* @param None
* @retval None
*/
void USART_Config(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
RCC_AHBPeriphClockCmd( RCC_AHBPeriph_GPIOA, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE );
GPIO_PinAFConfig(GPIOA,GPIO_PinSource9,GPIO_AF_1);
GPIO_PinAFConfig(GPIOA,GPIO_PinSource10,GPIO_AF_1);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9|GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
USART_InitStructure.USART_BaudRate = 115200;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(USART1, &USART_InitStructure);
USART_Cmd(USART1, ENABLE);
USART_ITConfig(USART1,USART_IT_RXNE,ENABLE);
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
……………………
…………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼
所有資料51hei提供下載:
STM32F030C8T6串口例程.zip
(487.8 KB, 下載次數: 549)
2017-11-28 10:30 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
作者:
hackxt
時間:
2018-7-10 10:33
感謝分享!!!!
作者:
haiqingxiao
時間:
2018-7-19 15:48
下載了,不錯,謝謝!!
作者:
笑淺
時間:
2018-10-17 18:21
下載,好東西
作者:
lxiaoxi
時間:
2019-9-26 14:54
感謝分享!!!!
作者:
471097604
時間:
2019-9-26 21:15
正在找這個呢
作者:
esmember
時間:
2019-9-27 08:23
這個可以有,不過想屏蔽一下串口呢。
作者:
MR.Xuan
時間:
2019-10-11 11:28
有空下來看看
作者:
nonplus
時間:
2019-12-30 10:02
感謝分享!!!!
作者:
vivianb
時間:
2019-12-30 15:33
謝謝分享,不錯的東西
作者:
GlenXu
時間:
2020-1-19 11:52
感謝分享,學習了!
作者:
mspの心
時間:
2021-6-10 17:38
感謝樓主的分享,部分疑惑解答了
作者:
ddddabv
時間:
2022-5-30 15:47
好用嗎?
作者:
LEO_Huang
時間:
2022-6-1 12:03
贊,正在找串口程序。
作者:
阿牛——牛
時間:
2023-1-6 13:38
剛下載了,不錯,正在學習中
歡迎光臨 (http://m.zg4o1577.cn/bbs/)
Powered by Discuz! X3.1
主站蜘蛛池模板:
狠狠网
|
亚洲成人一区二区
|
羞羞网站在线观看
|
日本加勒比在线观看
|
美女免费视频网站
|
夜夜骚av
|
色综合天天
|
日韩不卡免费视频
|
中文字幕一区二区三区视频
|
免费成人黄色
|
亚洲精品在
|
成人网在线观看
|
欧美三级韩国三级日本三斤在线观看
|
俺去俺来也在线www色官网
|
亚洲二三区
|
中文字幕在线观看日韩
|
日韩成人在线播放
|
影音先锋中文字幕在线
|
午夜黄色小视频
|
午夜激情福利
|
欧美午夜精品
|
成人动漫在线看
|
亚洲裸体视频
|
亚洲丝袜视频
|
成年人国产
|
法国极品成人h版
|
婷婷五月在线视频
|
日日爱影视
|
久久久久久久成人
|
日本高清中文字幕
|
www.狠狠操
|
午夜视频在线播放
|
中文文字幕文字幕高清
|
91成人免费视频
|
色婷婷精品
|
黄色成人小视频
|
亚洲砖区区免费
|
中文字幕少妇
|
成人精品福利
|
91蜜桃视频
|
欧美视频一区
|