STM学习笔记(二)

这周的作业又来了。

1.编程实现通过串口1发送字符串"you are welcome"

2.简述FSMC从初始化的流程及RA875初始化的流程,画出流程图。

这周的课,我依旧是没听。要么听不懂,要么已经会了,然后就懒得听了。又要开始自学了。

第一题

题目一是要求使用串口1。串口1初始化

void USART_Configuration(void){
USART_InitTypeDef USART_InitStructure;
USART_InitStructure.USART_BaudRate = 9600;//设置了 USART 传输的波特率
USART_InitStructure.USART_WordLength = USART_WordLength_8b;//h 提示了在一个帧中传输或者接收到的数据位数
USART_InitStructure.USART_StopBits = USART_StopBits_1;//定义了发送的停止位数目 USART_InitStructure.USART_Parity = USART_Parity_Odd;//定义了奇模式 USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_RTS_CTS;//指定了硬件流控制模式使能 USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;//指定了使能或者失能发送和接收模式
USART_InitStructure.USART_Clock = USART_Clock_Disable;// 提示了 USART 时钟使能还是失能,时钟低电平活动
USART_InitStructure.USART_CPOL = USART_CPOL_High;//指定了下 SLCK 引脚上时钟输出的极性,时钟高电平 
USART_InitStructure.USART_CPHA = USART_CPHA_1Edge;//指定了下 SLCK 引脚上时钟输出的相位,和 CPOL 位一起配合来产生用户希望的时钟/数据 的采样关系,时钟第一个边沿进行数据捕获 
USART_InitStructure.USART_LastBit = USART_LastBit_Enable;//后一位数据的时钟脉冲从 SCLK 输出 
USART_Init(USART1, &USART_InitStructure)//根据已填写的参数初始化串口1
USART_Cmd(ENABLE);//使能串口1
}

使能串口1时钟

RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1);

总程序:


#include "stm32f10x.h"  
#include "stm32f10x_rcc.h"  

#include "stm32f10x_usart.h" 
#include "stm32f10x_crc.h"
#include "system_stm32f10x.h" 
#include "stdio.h" 

void USART_Configuration(void); 
char str[] = "you are welcome ";
  int i;
int main()
{               
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE);    
    USART_Configuration(); 
    while(1)
{
for(i=0;i<15;i++){
      UART_SendData(USART1, char[i]); 
while(!USART_GetFlagStatus (USART1,USART_FLAG_TXE));
}
    } 
}
  
void USART_Configuration(void)//串口初始化函数  
{  
    USART_InitTypeDef USART_InitStructure;               //串口设置恢复默认参数  
    //初始化参数设置  
    USART_InitStructure.USART_BaudRate = 9600;                  //波特率9600  
    USART_InitStructure.USART_WordLength = USART_WordLength_8b; //字长8位  
    USART_InitStructure.USART_StopBits = USART_StopBits_1;      //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;//打开Rx接收和Tx发送功能  
    USART_Init(USART1,&USART_InitStructure);                   //初始化  
    USART_Cmd(USART1,ENABLE);                                  //启动串口  
}

第二题

FSMC初始化流程

RA8875初始化流程

流程图

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值