博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
avr flash_AVR | USART家庭自动化
阅读量:2530 次
发布时间:2019-05-11

本文共 3257 字,大约阅读时间需要 10 分钟。

avr flash

The Universal Synchronous and Asynchronous serial Receiver and Transmitter (USART) is a highly flexible serial communication device. The main features are:

通用同步和异步串行接收器和发送器(USART)是一种高度灵活的串行通信设备。 主要特点是:

  • Full Duplex Operation (Independent Serial Receive and Transmit Registers)

    全双工操作(独立的串行接收和发送寄存器)

  • Asynchronous or Synchronous Operation

    异步或同步操作

  • Master or Slave Clocked Synchronous Operation

    主或从时钟同步操作

  • High-Resolution Baud Rate Generator

    高分辨率波特率发生器

  • Supports Serial Frames with 5, 6, 7, 8, or 9 Data Bits and 1 or 2 Stop Bits

    支持具有5、6、7、8或9个数据位和1或2个停止位的串行帧

  • Odd or Even Parity Generation and Parity Check Supported by Hardware

    硬件支持奇偶校验生成和奇偶校验

  • Data Overrun Detection

    数据溢出检测

  • Framing Error Detection

    帧错误检测

  • Noise Filtering Includes False Start Bit Detection and Digital Low Pass Filter

    噪声过滤包括错误的起始位检测和数字低通滤波器

  • Three Separate Interrupts on TX Complete, TX Data Register Empty, and RX Complete

    TX完成,TX数据寄存器为空和RX完成的三个独立中断

  • Multi-processor Communication Mode

    多处理器通讯模式

  • Double Speed Asynchronous Communication Mode

    双速异步通讯模式

These are some of the features of USART, we would now lean to create a program in which we would use Bluetooth technology to open and close a LED bulb. In our program, we would take a variable X, such that if X=A our bulb will glow and if X=B the bulb will stop glowing.

这些是USART的一些功能 ,我们现在倾向于创建一个程序,在该程序中,我们将使用蓝牙技术打开和关闭LED灯泡。 在我们的程序中,我们将使用变量X ,使得如果X = A ,则灯泡将发光,如果X = B,则灯泡将停止发光。

In the similar we can also use a fan instead of LED, then we would be controlling our Fan to start or stop.

同样,我们也可以使用风扇代替LED,然后控制风扇启动或停止。

Program:



程序:

</ s> </ s> </ s>
#include 
void usart_string(char*);int main(void){
char x; DDRA = 0x01; UBRRL= 51; UCSRB= 0x18; UCSRC= 0x86; usart_string("Sam"); while(1) {
while((UCSRA&(1<

Explanation:

说明:

  • Write all the header files as written above.

    像上面那样写所有的头文件。

  • Take a variable X which will decide whether our bulb will be ON or OFF.

    取一个变量X来决定我们的灯泡是开还是关

  • DDRA=0x01 indicates that the Led bulb is connected.

    DDRA = 0x01指示LED灯泡已连接。

  • UBRRL=51; indicates that the baud rate is set to 9600.

    UBRRL = 51; 表示波特率设置为9600

  • UCSRB=0x18 means Rx and Tx are enabled.

    UCSRB =为0x18装置R XT X被启用。

  • The usart_string will print the word written inside it.

    usart_string将打印其中写入的单词。

  • Inside the while loop, we have written our bulb glowing condition such that when A is received the LED will glow and when B is received the LED bulb will stop glowing.

    在while循环内,我们编写了灯泡发光条件,以便当接收到A时LED发光,而当接收到B时LED灯泡停止发光。

BAUD RATE

波特率

It is the rate at which the information is processed/transferred to the communication channel.

它是信息被处理/传输到通信通道的速率。

Calculation of BAUD RATE

波特率的计算

Calculation of BAUD RATE

Where, fOSC is "System Oscillator Clock Frequency".

其中, fOSC“系统振荡器时钟频率”

Simulation:

模拟:

USART Simulation

Explanation:

说明:

  • Select the following components:

    选择以下组件:

    1. Atmega16
    2. LED Red
    3. From virtual instruments mode select a VIRTUAL TERMINAL
  • Add the components as shown in the figure.

    如图所示添加组件。

  • Double click on ATmega16 and make its speed as 8000000 and upload the hex file in it.

    双击ATmega16,使其速度达到8000000,并在其中上传十六进制文件。

  • When we will start the simulation a screen will appear that would be our simulation for a Bluetooth screen.

    当我们开始仿真时,将出现一个屏幕,该屏幕将是我们对蓝牙屏幕的仿真。

  • Typing A will glow the bulb and typing B will stop the bulb from glowing.

    键入A将使灯泡发光,键入B将使灯泡停止发光。

翻译自:

avr flash

转载地址:http://qkxzd.baihongyu.com/

你可能感兴趣的文章
点云PCL中小细节
查看>>
铁路信号基础
查看>>
RobotFramework自动化2-自定义关键字
查看>>
[置顶] 【cocos2d-x入门实战】微信飞机大战之三:飞机要起飞了
查看>>
BABOK - 需求分析(Requirements Analysis)概述
查看>>
第43条:掌握GCD及操作队列的使用时机
查看>>
Windows autoKeras的下载与安装连接
查看>>
CMU Bomblab 答案
查看>>
微信支付之异步通知签名错误
查看>>
2016 - 1 -17 GCD学习总结
查看>>
linux安装php-redis扩展(转)
查看>>
Vue集成微信开发趟坑:公众号以及JSSDK相关
查看>>
技术分析淘宝的超卖宝贝
查看>>
i++和++1
查看>>
react.js
查看>>
P1313 计算系数
查看>>
NSString的长度比较方法(一)
查看>>
Azure云服务托管恶意软件
查看>>
My安卓知识6--关于把项目从androidstudio工程转成eclipse工程并导成jar包
查看>>
旧的起点(开园说明)
查看>>