欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標(biāo)題:
STM32F030C8T6串口例程
[打印本頁]
作者:
liweijin66
時間:
2017-11-28 09:44
標(biāo)題:
STM32F030C8T6串口例程
現(xiàn)在提供STM32F030C8T6串口例程,適合初學(xué)上手
單片機源程序如下:
/**
******************************************************************************
* @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黑下載附件…………
復(fù)制代碼
所有資料51hei提供下載:
STM32F030C8T6串口例程.zip
(487.8 KB, 下載次數(shù): 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
感謝分享,學(xué)習(xí)了!
作者:
mspの心
時間:
2021-6-10 17:38
感謝樓主的分享,部分疑惑解答了
作者:
ddddabv
時間:
2022-5-30 15:47
好用嗎?
作者:
LEO_Huang
時間:
2022-6-1 12:03
贊,正在找串口程序。
作者:
阿!
時間:
2023-1-6 13:38
剛下載了,不錯,正在學(xué)習(xí)中
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1