avr单片机教程 csdn

If you are into the Atmel microcontroller camp, chances are if you are adding some degree of automation to your electronic project you have heard of the popular ATtiny85 microcontroller, launched back all the way in 2005 (who would have thought!).

如果您进入Atmel微控制器阵营,则有可能在您的电子项目中增加某种程度的自动化,您会听说流行的ATtiny85微控制器,该微控制器于2005年问世。

Found in projects ranging from a somewhat complex USBtinyISP programmer (a low cost ISP programmer), to simple NeoPixel LED strip drivers, to some more impressive ones such as Pulse Oximeters. If your design does not require many IOs, there’s a high chance you’ll use one. Because let’s face it, there are tons of resources online and the device is pretty inexpensive; and like with any other electronic project, it’s highly likely you will run into a problem when building your gadget, be it an unexpected short circuit (don’t let magic smoke happen!), failure during programming, etc. Trust me, all those resources come in handy so you find and fix any error.

从一些复杂的USBtinyISP编程器(一种低成本ISP编程器)到简单的NeoPixel LED灯条驱动器,再到一些更令人印象深刻的产品(例如脉搏血氧仪),都可以找到这些项目。 如果您的设计不需要很多IO,则很有可能会使用一个。 因为我们面对现实,所以在线上有大量资源,而且该设备非常便宜。 就像任何其他电子项目一样,在构建小工具时,很可能会遇到问题,例如意外的短路(不要让魔术冒烟!),编程过程中的失败等等。相信我,所有这些资源会派上用场,因此您可以查找并修复任何错误。

Impressive amount of results for such a tiny chip
如此微小的芯片带来令人印象深刻的结果

The project I wanted to build (which you can check out the story here) was ‘somewhat’ straightforward, I had a RN4020 Bluetooth LE module that needed some initialization via it’s UART interface, and was going to hand over the communication to a USB to UART IC once the configuration was done. Having used the ATtiny85 in the past I know first hand that I am in for a wild ride if I want to have full duplex UART communication as the chip does not have an built in peripheral, only that not so friendly to configure USI (Universal Serial Interface); and using any ATmega was out of the question since I had a target size for the PCB.

我想要构建的项目(您可以在此处查看故事)非常简单,我有一个RN4020蓝牙LE模块,该模块需要通过其UART接口进行一些初始化,并将通信传递给USB,完成配置后,UART IC。 过去曾经使用过ATtiny85,如果我想进行全双工UART通信,因为该芯片没有内置的外设,那么我就亲身经历了一次疯狂的旅程,只是对配置USI不太友好(通用串行)接口); 因为我有PCB的目标尺寸,所以使用任何ATmega都是不可能的。

Block diagram of the mighty ATtiny85, no UART module to be found =(
强大的ATtiny85的框图,找不到UART模块=(

I started to wonder what chip would fit my bill since most projects I've done in the past usually involve a 64 pin or higher packages, so I decided to visit Microchip’s website and search for parts they have available.

我开始怀疑哪种芯片适合我的账单,因为我过去完成的大多数项目通常都使用64引脚或更高的封装,因此我决定访问Microchip网站并搜索它们可用的零件。

That’s too many results, let’s narrow it down
结果太多,让我们缩小范围

Luckily their parametric search engine was comprehensive. Since I was aiming to 1 UART module in the tiniest available package, I navigated through the columns to select the features I needed and was left with few results.

幸运的是,他们的参数搜索引擎非常全面。 由于我的目标是使用最小的可用软件包中的1个UART模块,因此我在各列中进行导航以选择所需的功能,但结果很少。

Success!
成功!

Two parts stood out, the ATtiny402, and ATtiny412; not that different in price and feature set I went ahead with the ATtiny412. Then I paid a visit to my favorite parts supplier Mouser to check on it’s availability, because there’s no use if that chip is right for us but we can’t buy it, right?

两个部分脱颖而出,分别是ATtiny402和ATtiny412; 在价格和功能上没什么不同,我继续使用ATtiny412。 然后,我拜访了我最喜欢的零件供应商Mouser,以检查其可用性,因为该芯片是否适合我们,但我们无法购买,对吗?

That’s some good availability. Awesome!
那是一些良好的可用性。 太棒了!

Before making the commitment, I went ahead and checked the chip’s datasheet.

在做出承诺之前,我继续检查了芯片的数据表。

We always need to check the fine print of each device we use, otherwise we might be in for a nasty surprise when your gadget is not doing what you expected

我们始终需要检查我们使用的每台设备的打印效果,否则,当您的小工具未达到您的预期效果时,我们可能会感到讨厌

A very prominent hint staring right at us! Sure it must mean something, right?
一个非常突出的提示正盯着我们! 确定一定意味着什么,对吧?

My focus was on knowing how setup the UART interface and the digital IO as I wanted to read one of the RN4020’s outputs to know when ATtiny was ready to let go of the serial lines.

我的重点是在了解如何设置UART接口和数字IO时,因为我想读取RN4020的输出之一,以了解ATtiny准备何时松开串行线。

Look at those peripherals! An UPDI interface? I wonder what that is…
看看那些外围设备! UPDI接口? 我不知道那是什么...

Out of sheer curiosity I decided to check on example projects and documentation from Microchip’s website to see if there was a big difference in between one family and the other. So I went ahead and checked the related documents in the chip product page I was greeted with a healthy app note catalog.

出于好奇,我决定查看Microchip网站上的示例项目和文档,以了解一个家庭与另一个家庭之间是否存在很大差异。 因此,我继续检查了芯片产品页面中的相关文档,并收到了健康的应用笔记目录。

Oh, hi there! Just what I was looking for.
哦,你好! 正是我想要的。

After scrolling through some pages inside the Getting started with USART I was greeted with the first code snippet:

在浏览《 USART入门》中的某些页面后我看到了第一个代码段:

USART0.BAUD  = (uint16_t) USART0_BAUD_RATE(BAUD_RATE);

Being acquainted with data structures from my days in college and few projects of my own, I did not pay much attention. But then it hit me…

上大学时就熟悉数据结构,而我自己的项目很少,所以我并没有特别注意。 但是后来打了我…

C

C

#define UCSR0B  _SFR_MEM8(0xC1)       //Like this oneUCSR0B = (1 << TXEN0) | (1 << RXEN0); //And we use them like this

So I decided to look inside the definition file and sure enough found a data structure, sweet!

因此,我决定查看定义文件,并确保找到了足够的数据结构!

hello, there!
你好!

Nothing to worry about, it just means we must to use one of the C operators to access data structure.

不用担心,这仅意味着我们必须使用C操作符之一来访问数据结构。

We need to use the dot (.) operator to access the structure members i.e. the variables inside the structure

我们需要使用点(。)运算符来访问结构成员,即结构内部的变量

All that remained was to read the chip’s datasheet to know what bits to set, just like any other Atmel microcontroller.

剩下的就是读取芯片的数据表,以了解要设置哪些位,就像其他任何Atmel微控制器一样。

Moving onto the digital IOs, I checked the Getting Started with GPIO file, and just like the USART configuration after a few pages I was greeted with a similar code snippet.

转到数字IO,我检查了GPIO文件入门 就像几页后的USART配置一样,我收到了类似的代码片段。

PORTn.DIR = PORTn.DIR | PINx_bm;

I felt acquainted with the bit manipulation and logic operators used by Microchip in their example. But given that we now were dealing with data structures, I checked again the definition file to be sure what members the structure had.

我感到熟悉Microchip在其示例中使用的位操作和逻辑运算符。 但是鉴于我们现在正在处理数据结构,因此我再次检查了定义文件以确保该结构具有哪些成员。

much members, much wow!
很多成员,很多哇!

And there were a couple of variables that intermediately gained my attention. Each of the marked members is a shortcut to each of the operations you can do with the ports, just like bitwise operations!

并且有两个变量引起了我的注意。 每个标记成员都是您可以对端口执行的每个操作的快捷方式,就像按位操作一样!

We can use those shortcuts to avoid the common mistakes of logic operations such as setting a pin as input or output, or pull it high or low incorrectly.

我们可以使用这些快捷方式来避免逻辑操作的常见错误,例如将引脚设置为输入或输出,或者将其错误地拉高或拉低。

PORTA.OUTSET = PIN7_bm; //Setting the PIN using the 'new' wayPORTA.OUT |= PIN7_bm;   //Or the old way using bitwise operationsPORTA.DIRSET = PIN7_bm; //Setting the pin as output

With the new ‘coding approach’ now in mind I started working on my program, a simulation here and there. Once I was satisfied with the overall flow; it was time to load the program into the chip. And oh boy I was in for a surprise, it turns out that the new AVR 1 series does not use the well known ISP programming interface! They use the Unified Program and Debug Interface (UPDI), which means that you only need a couple of pins to load your program, and best of all is that if you want to use hardware debugging to debug your code, there’s no need to set fuses anymore that have the potential to brick your device if not done properly!

现在考虑到新的“编码方法”,我开始编写程序,到处都是模拟。 一旦我对整体流程感到满意; 是时候将程序加载到芯片了。 哦,天哪,我很惊讶,事实证明,新的AVR 1系列没有使用众所周知的ISP编程接口! 他们使用统一程序和调试接口(UPDI),这意味着您只需要几个引脚即可加载程序,最重要的是,如果您要使用硬件调试来调试代码,则无需设置如果操作不当,保险丝可能会堵塞您的设备!

Not the most affordable, but it does the trick nicely!
不是最负担得起的,但是可以很好地解决问题!

But if you do not feel like spending that much on an Atmel ICE or are on a budget, and have some Arduino compatible boards laying around, you can build a low cost UPDI programmer(click here to go to the post), the only thing you will be missing is the hardware debugging.

但是,如果您不想在Atmel ICE上花费那么多或预算有限,并且周围有一些Arduino兼容板,则可以构建一个低成本的UPDI程序员(单击此处转到帖子),这是唯一的选择您将缺少的是硬件调试。

成功! (Success!)

Now that you have the basics, you can easily dive deeper into other peripherals and take advantage of how easy to use the new chips are and tinker to your heart desires.

掌握了基础知识之后,您就可以轻松地深入其他外围设备,并充分利用新芯片的易用性并满足您的内心需求。

Using this new chip series enables you to speed up your projects by a long shot instead of wasting tons of time trying to hack around your way into getting to work something as simple an UART interface, your clients or bosses might thank you for it.

使用这个新的芯片系列可以使您从长远来看加快项目的开发速度,而不会浪费大量时间试图利用简单的UART接口工作,您的客户或老板可能会对此表示感谢。

I hope you’ve enjoyed this brief introduction to the new AVR series!

希望您喜欢新的AVR系列的简要介绍!

If you liked this post, you can also have a look at my own website nicatronix.com that I am currently building to share more related stuff on Electronics!

如果您喜欢这篇文章,您也可以看看我自己正在建立的自己的网站nicatronix.com ,以分享电子方面的更多相关信息!

翻译自: https://medium.com/@lestherborge/an-upgrade-from-the-venerable-attiny85-to-the-new-avr-1-series-an-attiny412-tutorial-617932d31138

avr单片机教程 csdn


http://www.taodudu.cc/news/show-2093239.html

相关文章:

  • 单片机开发环境要求java地址_AVR单片机教程——开发环境配置
  • AVR单片机项目教程 基于C语言,AVR单片机项目教程--基于C语言(第2版)
  • java 定时器 的中断程序,AVR单片机教程——定时器中断
  • AVR单片机教程——UART进阶
  • AVR单片机教程——DAC
  • Eviews10.0下载与安装
  • eviews建立时间序列模型_Eviews教程 Eviews进行时间序列分析教程
  • 中国居民消费价格指数(CPI)月度汇总数据集(1990.1.31--2020.2.29)
  • Eviews下载及安装
  • Eview操作步骤——数据导入及数据建模
  • 利用EViews做截面数据的线性回归分析
  • 建模必备软件下载
  • 【零基础Eviews实例】01异方差的检验与修正
  • Eviews9.0---软件安装
  • eviews时间序列分析课堂笔记
  • Eviews做ARIMA模型
  • EViews10.0程序安装及注意事项
  • EViews11.0程序安装及注意事项
  • eviews建立时间序列模型_如何用eviews分析时间序列(全面).pdf
  • Eviews创建散点图的具体方法
  • eviews9.0详细安装步骤
  • Eviews10下载及安装
  • 第一章 Eviews10下载及安装和数据录入
  • 前端Photoshop插件cutterman的下载和安装以及使用
  • Photoshop插件-加深减淡中灰图-脚本开发-PS插件
  • Photoshop插件-保存-存为Web所用格式-另存为-脚本开发-PS插件
  • Photoshop插件-保存-转换sRGB-脚本开发-PS插件
  • Photoshop插件-HDR(二)-脚本开发-PS插件
  • Photoshop插件-证件照-白红蓝底-PS插件-脚本开发
  • photoshop 插件_Photoshop的线性光

avr单片机教程 csdn_从古老的attiny85升级到新的AVR 1系列attiny412教程相关推荐

  1. avr单片机led数码管六位动态显示时分秒c语言程序,AVR单片机控制8段LED数码管同时显示 - AVR单片机8位数码管显示的程序实现(两种方法介绍)...

    AVR单片机控制8段LED数码管同时显示 这是一个简单的供单片机入门学习者练习用的8段LED数码管控制汇编程序,控制一个两位的数码管同时显示字符(动态刷新).用AVR- Studio-4 开发,在AV ...

  2. avr单片机led数码管六位动态显示时分秒c语言程序,AVR单片机8位数码管显示的程序实现(两种方法介绍)...

    描述 本文为大家介绍两个AVR单片机8位数码管显示的程序实现. AVR单片机595驱动8位数码管的显示的电路实现 主程序代码 #include > #include //GCC中的延时函数头文件 ...

  3. 关于《十天学会AVR单片机》的教程头文件AVR_PQ1A.h

    最近开始学习AVR单片机,由于之前买的51开发板是兼容AVR单片机的,所以就没有必要开发板了.于是从网上找了一个教程<十天学会AVR单片机>,也是郭天祥公司的人讲的,觉得还可以.因为没有买 ...

  4. 利用AVR单片机 专用下载 USBtinyISP对Arduino UNO下载程序

    简 介: 测试了利用USBtinyISP对于Arduino UNO,也就是ATmega系列的单片机下载Bootloader的过程.通过测试可以看到,利用USBtinyISP可以更快的下载ATmega系 ...

  5. AVR单片机特性简介

    AVR单片机是ATMEL公司在1997年研发的增强型内置Flash的RISC精简指令集高速单片机.可以广泛应用于计算机外部设备.工业实时控制.仪器仪表.通讯设备.家用电器等各个领域. 一. AVR单片 ...

  6. AVR单片机与C语言的一些入门简要概述

    用C语言进行嵌入式系统的开发具有汇编语言编程不可比拟的优势,虽然C语言编写出的代码要比汇编语言占有的空间大5%~20%,但是由于半导体技术的发展,芯片的容量和速度有了大幅度的提升,占用空间的比例已经不 ...

  7. avr c语言编译器,[VR虚拟现实]AVR单片机C语言编译器.doc

    (VR虚拟现实)AVR单片机C语言编译器 AVR单片机C语言编译器 Win-AVR是流行的GNU编译器在AVR平台上的移植.安装完毕后会在桌面上出现一下七个快捷方式,它们的作用如下: Programm ...

  8. c语言编译器只有9行怎么添加,avr单片机c语言编译器(9页)-原创力文档

    AVR单片机C语言编译器 Win-AVR是流行的GNU编译器在AVR平台上的移植.安装完毕后会在桌面上出现一下七 个快捷方式,它们的作用如下: Programmers Notepad 源文件的编辑软件 ...

  9. ds18b20温度传感器 lcd C语言,基于AVR单片机的18B20温度传感器及LCD显示的C语言程序设计...

    ***************************************************/ #include #include #define uchar unsigned char # ...

  10. AVR单片机网址推荐

    1.  EG3 关于嵌入式开发的站点,提供非常多关于嵌入式开发的资料.包括开发公司,技术文档,免费资源等等.版面包括busses & boards,embedded software,dsp, ...

最新文章

  1. python爬虫抓取信息_python爬虫爬取网上药品信息并且存入数据库
  2. 欧盟AI道德准则草案出炉
  3. linux root------系统排错
  4. java中利用框架传入相同的url实现crud操作_还在手写CRUD代码?这款开源框架助你解放双手!
  5. 苹果笔记本电脑电池保养细则
  6. c语言窗口程序 画圆,C语言画圆问题。怎么跳过画图界面直接出来了?
  7. Go语言的分词器(sego)
  8. TensorFlow CIFAR-10数据集
  9. 从golang-gin-realworld-example-app项目学写httpapi (四)
  10. ORACLE数据库自动备份压缩的批处理脚本 rar 7z
  11. java 匿名函数_国外程序员用的火热的Vavr是什么鬼?让函数式编程更简单!
  12. 台大陈蕴侬、李宏毅“应用深度学习”课程(国语)
  13. bzoj3944 Sum
  14. zendstudio 的使用过程中出现 Editor could not be initialized. 的问题
  15. 突然想起来几年前我写的 !
  16. Linux下C语言编程入门-8关于计时器
  17. 马尔科夫区制转移向量自回归模型,MSVAR模型,MS-VAR模型的使用和操作过程
  18. 甘肃省学业水平测试计算机,甘肃省信息技术学业水平测试试卷
  19. 对于初学者的JavaScript 教程
  20. 计算机动态评估英语阅读,动态评价理论的国内外研究简述

热门文章

  1. 微信小程序的下载安装
  2. USBoot /WinHex恢复故障U盘的数据文件
  3. 数据处理-倾斜摄影OSGB合并根节点
  4. java各种异常总结
  5. mysql的pom文件在哪_Maven中pom文件详解
  6. Excel技巧—超实用的字符串拆分小技巧
  7. 目前总结最新最系统的Java程序员未来职业规划路线,请收藏
  8. 异步社区本周(3.26-4.1)半价电子书
  9. 红外图像和可见光图像异源图像配准问题研究
  10. 2019软考软件评测师考试大纲