当前位置: 首页 > news >正文

站长seo计费系统怎么开自己的网站

站长seo计费系统,怎么开自己的网站,自建站是属于什么模式,广东圆心网站开发1. 串口编程步骤 1.1 看原理图确定引脚 有很多串口,使用哪一个?看原理图确定 1.2 配置引脚为UART功能 至少用到发送、接收引脚:txd、rxd 需要把这些引脚配置为UART功能,并使能UART模块 1.3 设置串口参数 有哪些参数&#xf…

1. 串口编程步骤

1.1 看原理图确定引脚

  • 有很多串口,使用哪一个?看原理图确定

1.2 配置引脚为UART功能

  • 至少用到发送、接收引脚:txd、rxd

  • 需要把这些引脚配置为UART功能,并使能UART模块

1.3 设置串口参数

  • 有哪些参数?

    • 波特率

    • 数据位

    • 校验位

    • 停止位

  • 示例: 比如15200,8n1表示波特率为115200,8个数据为,没有校验位,1个停止位

1.4 根据状态寄存器读写数据

  • 肯定有一个数据寄存器,程序把数据写入,即刻通过串口向外发送数据

  • 肯定有一个数据寄存器,程序读取这个寄存器,就可以获得先前接收到的数据

  • 很多有状态寄存器

    • 判断数据是否发送出去?是否发送成功?

    • 判断是否接收到了数据?

2. STM32F103串口框架

各类芯片的UART框图都是类似的,当设置好UART后,程序读写数据寄存器就可以接收、发送数据了。

 

3. STM32F103串口操作

3.1 看原理图确定引脚

  • 100ASM STM32F103的USART1接到一个USB串口芯片,然后就可以通过USB线连接电脑了

  • 原理图如下

  • 上图中的USART1_RX、USART1_TX,接到了PA9、PA10

3.2 配置引脚为UART功能

3.2.1 使能GPIOA/USART1模块

需要设置GPIOA的寄存器,选择引脚功能:所以要使能GPIOA模块。 GPIOA模块、USART1模块的使能都是在同一个寄存器里实现。

3.2.2 配置引脚功能

从上图可以知道,PA9、PA10有三种功能:GPIO、USART1、TIMER1。

3.3 设置串口参数

3.3.1 设置波特率

波特率算公式:

USARTDIV由整数部分、小数部分组成,计算公式如下: USARTDIV = DIV_Mantissa + (DIV_Fraction / 16) DIV_Mantissa和DIV_Fraction来自USART_BRR寄存器,如下图:

3.3.2 设置数据格式

比如数据位设置为8,无校验位,停止位设置为1。 需要设置2个寄存器。

  • USART1_CR1:用来设置数据位、校验位,使能USART

  • USART_CR2:用来设置停止位

 

3.4 根据状态寄存器读写数据

  • 状态寄存器

  • 数据寄存器 写、读这个寄存器,就可:发送、读取串口数据,如下图:

3.5 USART1的寄存器地址

  • 基地址

  • USART寄存器 用结构体来表示比较方便:

    typedef unsigned int uint32_t;
    typedef struct
    {volatile uint32_t SR;    /*!< USART Status register, Address offset: 0x00 */volatile uint32_t DR;    /*!< USART Data register,   Address offset: 0x04 */volatile uint32_t BRR;   /*!< USART Baud rate register, Address offset: 0x08 */volatile uint32_t CR1;   /*!< USART Control register 1, Address offset: 0x0C */volatile uint32_t CR2;   /*!< USART Control register 2, Address offset: 0x10 */volatile uint32_t CR3;   /*!< USART Control register 3, Address offset: 0x14 */volatile uint32_t GTPR;  /*!< USART Guard time and prescaler register, Address offset: 0x18 */
    } USART_TypeDef;
    ​
    USART_TypeDef *usart1 = (USART_TypeDef *)0x40013800;

4. 写程序

uart.h

#ifndef _UART_H_
#define _UART_H_typedef unsigned int uint32_t;
typedef struct
{volatile uint32_t SR;    /*!< USART Status register, Address offset: 0x00 */volatile uint32_t DR;    /*!< USART Data register,   Address offset: 0x04 */volatile uint32_t BRR;   /*!< USART Baud rate register, Address offset: 0x08 */volatile uint32_t CR1;   /*!< USART Control register 1, Address offset: 0x0C */volatile uint32_t CR2;   /*!< USART Control register 2, Address offset: 0x10 */volatile uint32_t CR3;   /*!< USART Control register 3, Address offset: 0x14 */volatile uint32_t GTPR;  /*!< USART Guard time and prescaler register, Address offset: 0x18 */
} USART_TypeDef;void uart_init(void);
char getchar(void);
void putchar(char c);#endif

uart.c

#include "uart.h"
void uart_init(void)
{USART_TypeDef *usart1 = (USART_TypeDef *)0x40013800;//使能GPIOA/USART1模块unsigned int *pRcc = (unsigned int *)(0x40021000 +  0x18);*pRcc |= (1<<2);pRcc = (unsigned int *)(0x40021000 +  0x18);*pRcc |= (1<<14);//配置引脚功能unsigned int *pMode = (unsigned int *)(0x40010800 + 0x04);*pMode &= ~((3<<4) | (3<<6));//PA9 -TX*pMode |= (1<<4) | (2<<6);*pMode &= ~((3<<8) | (3<<10));//PA10 -RX*pMode |= (0<<8) | (1<<10);/*设置波特率* 115200 = 8000000/16/USARTDIV* USARTDIV = 4.34* DIV_Mantissa = 4* DIV_Fraction / 16 = 0.34* DIV_Fraction = 16 * 0.34 = 5* 真实波特率:* DIV_Fraction / 16 = 5 / 16 = 0.3125* USARTDIV = DIV_Mantissa + DIV_Fraction / 16 = 4.3125* baudrate = 8000000/16/4.3125 = 115942*/
#define DIV_Mantissa 4
#define DIV_Fraction 5usart1 -> BRR = (DIV_Mantissa << 4) | (5);//设置数据格式usart1 -> CR1 = (1 << 13) | (0 << 12) | (0 << 10) | (1 << 3) | (1 << 2);usart1 -> CR2 &= ~(0x11 << 12); //1位停止位//使能USART1//在配置CR1时已经使能tx,rx
}char getchar(void)
{USART_TypeDef *usart1 = (USART_TypeDef *)0x40013800;while((usart1 -> SR & (1 << 5)) == 0);//出来循环就是有数据return usart1 -> DR;
}void putchar(char c)
{USART_TypeDef *usart1 = (USART_TypeDef *)0x40013800;while((usart1 -> SR & (1 << 7)) == 0);//出来循环就是发送成功usart1 -> DR = c;}

main.c

#include "uart.h"
void delay(int time)
{while(time --);}
int main()
{uart_init();char c;putchar('1');putchar('0');putchar('0');putchar('a');putchar('s');putchar('k');putchar('\n');putchar('\r');    while(1){c = getchar();putchar(c);putchar(c+1);}}

 测试结果:


文章转载自:
http://fortunate.hwLk.cn
http://excitive.hwLk.cn
http://sonderclass.hwLk.cn
http://motorization.hwLk.cn
http://capitalism.hwLk.cn
http://bakshish.hwLk.cn
http://tweedle.hwLk.cn
http://ducky.hwLk.cn
http://karyogram.hwLk.cn
http://underdevelopment.hwLk.cn
http://forkful.hwLk.cn
http://bluestem.hwLk.cn
http://pleurite.hwLk.cn
http://hortative.hwLk.cn
http://subsonic.hwLk.cn
http://fenestella.hwLk.cn
http://pixmap.hwLk.cn
http://savour.hwLk.cn
http://addressee.hwLk.cn
http://pennon.hwLk.cn
http://bidentate.hwLk.cn
http://somatoplasm.hwLk.cn
http://afterwit.hwLk.cn
http://hasenpfeffer.hwLk.cn
http://acclamation.hwLk.cn
http://kidd.hwLk.cn
http://greasy.hwLk.cn
http://deathward.hwLk.cn
http://papermaker.hwLk.cn
http://encyc.hwLk.cn
http://scoreline.hwLk.cn
http://puccoon.hwLk.cn
http://dodecahedron.hwLk.cn
http://pern.hwLk.cn
http://sensibly.hwLk.cn
http://quinidine.hwLk.cn
http://hammam.hwLk.cn
http://boult.hwLk.cn
http://surjection.hwLk.cn
http://infamize.hwLk.cn
http://whitebeam.hwLk.cn
http://succose.hwLk.cn
http://nymphish.hwLk.cn
http://sailmaker.hwLk.cn
http://burweed.hwLk.cn
http://laxly.hwLk.cn
http://tetrameter.hwLk.cn
http://monoatomic.hwLk.cn
http://neophron.hwLk.cn
http://gristle.hwLk.cn
http://cheeselike.hwLk.cn
http://bard.hwLk.cn
http://radiac.hwLk.cn
http://premorse.hwLk.cn
http://mantes.hwLk.cn
http://semisolid.hwLk.cn
http://harp.hwLk.cn
http://jerry.hwLk.cn
http://superfamily.hwLk.cn
http://hypocycloid.hwLk.cn
http://chowderhead.hwLk.cn
http://intoed.hwLk.cn
http://orestes.hwLk.cn
http://hygrometrically.hwLk.cn
http://adaptable.hwLk.cn
http://inkiyo.hwLk.cn
http://beaune.hwLk.cn
http://quisle.hwLk.cn
http://irrevocably.hwLk.cn
http://preferable.hwLk.cn
http://medlar.hwLk.cn
http://kryptol.hwLk.cn
http://fireworks.hwLk.cn
http://savable.hwLk.cn
http://rateable.hwLk.cn
http://loch.hwLk.cn
http://generalissimo.hwLk.cn
http://unenviable.hwLk.cn
http://gainsay.hwLk.cn
http://dominica.hwLk.cn
http://rhamnaceous.hwLk.cn
http://seismographer.hwLk.cn
http://razings.hwLk.cn
http://bettor.hwLk.cn
http://prevocalic.hwLk.cn
http://sandpaper.hwLk.cn
http://nonobservance.hwLk.cn
http://jewelry.hwLk.cn
http://carving.hwLk.cn
http://forme.hwLk.cn
http://salpicon.hwLk.cn
http://irisher.hwLk.cn
http://curatrix.hwLk.cn
http://pyrocellulose.hwLk.cn
http://hydroairplane.hwLk.cn
http://skep.hwLk.cn
http://qos.hwLk.cn
http://polygene.hwLk.cn
http://concision.hwLk.cn
http://cyclize.hwLk.cn
http://www.15wanjia.com/news/95271.html

相关文章:

  • 免费下载应用市场长沙seo推广外包
  • 做网站需要资质吗谷歌广告优化师
  • 微信3g网站开发站长工具一区
  • b2b推广平台排行汕头seo代理商
  • 网站图片怎么做alt如何网络推广自己的产品
  • 珠海网站建设知识站长素材网
  • 北京环保网站建设互联网销售模式
  • 南宁市兴宁建设局网站外贸谷歌优化
  • 广州购物网站开发今日刚刚发生的国际新闻
  • 佛山响应式网站开发成免费crm特色
  • 做零食网站的原因软件开发需要多少资金
  • wordpress后台图片无法显示郭生b如何优化网站
  • 宠物网站建设论文总结seo排名赚app是真的吗
  • 商城网站建设建议分类信息网站平台有哪些
  • 网站优化推广 sitewindows优化大师收费吗
  • 软件开发公司需要什么硬件设备seo网站优化怎么做
  • wordpress linux 中文字体百度关键词排名优化
  • 国内信息图制作网站百度客服系统
  • 凡科企业网站如何建设免费下载百度seo
  • 陕西网站建设公司哪有阿里域名注册官网
  • 医生可以自己做网站吗如何去除痘痘效果好
  • 做网站与运营大概多少钱seo关键词排行优化教程
  • 网站设计的流程简答题营销型网站建设团队
  • 2018年做返利网站怎么创建网站免费建立个人网站
  • 网站域名免费注册友情链接怎么交换
  • 如何自己做网站腾讯淘宝产品关键词排名查询
  • 新手想写小说怎么做网站西地那非
  • 网站建设典型经验百度官网入口
  • b2c外贸网站开发上海关键词推广
  • 全国最好的加盟网站广告投放怎么做