AVR或PIC开始编程单片机?
我应该从哪个家庭开始学习? (从未在微控制器上进行过任何编程)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我应该从哪个家庭开始学习? (从未在微控制器上进行过任何编程)
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(20)
如今,AVR 和 PIC 可能是爱好者中最常见的微控制器。 两者都有非常广泛的设备变体,并且都可以用来实现类似的结果。
对于初学者,由于各种原因,我会建议 AVR:
AVR 系列(小型、大型)是连贯且易于理解的。 该架构功能强大且现代,特别适合 C 编译器。 AVR 当然也可以用汇编语言进行编程。
由于其 C 语言友好的架构,有高质量的 C 编译器可用,包括商业的和免费的。 无处不在的 GCC 被移植到 AVR 并称为 avr-gcc。
要开始使用,您真正需要的只是一些基本组件、AVR 芯片本身和面包板< /a>. 甚至 PC 和 AVR 之间的编程电缆也基本上可以免费构建(所谓的 wiggler)。 不过,有多种商业开发套件可供使用,其中最著名的是 Atmel 自己的 STK500。 商业开发套件是一种更昂贵的入门方式,但实际上不需要任何有关电子产品的先验知识。 例如,一些开发套件包含 LCD 显示器,因此可以轻松完成有趣的事情。
它有一个丰富的爱好者社区。
PIC 因其独特的架构而臭名昭著。 许多人喜欢 PIC,但也有人讨厌它。 AVR 更直接,似乎不会引起太多极端和两极分化的观点。
AVR 和 PIC 均用于许多重要的商业应用。 然而,它们当然不是唯一的选择。 我个人最喜欢的用于业余爱好和商业工作的微控制器是 Silicon Laboratories 的 C8051 系列,最著名的是 C8051F530。 有一个适用于 C8051 系列的优秀免费 C 编译器和汇编器,名为 SDCC。
摘要: 有很多选择,但请不要让这些选择淹没您。 只需选择一个并开始学习即可。 一旦您决定开始使用,微控制器确实非常容易掌握!
Today AVR and PIC are probably the most common microcontrollers among hobbyists. Both have a very wide range of device variants and both can be used to achieve similar results.
For a beginner I would suggest AVR due to various reasons:
AVR family (tiny, mega) is coherent and easy to understand. The architecture is powerful and modern, and is especially suitable for C compilers. AVRs can of course be programmed in assembly too.
Due to its C-friendly architecture, there are quality C compilers available, both commercial and free. The ubiquitous GCC is ported to AVR and called avr-gcc.
For getting started all you really need is a handful of basic components, the AVR chip itself and a breadboard. Even the programming cable between PC and AVR can be built essentially for free (a so called wiggler). However, several commercial development kits are available, most notably Atmel's own STK500. A commercial development kit is more expensive way for getting started, but doesn't require practically any prior knowledge about electronics. Some development kits contain for example LCD displays so it's easy to get interesting stuff done.
It has a rich hobbyist community.
PIC is notorious for its peculiar architecture. Many love PIC for this, some hate it. AVR is more straightforward and doesn't seem to cause as much extreme and polar opinions.
Both AVR and PIC are used in many serious commercial applications. However, they are not the only options of course. My personal favorite microcontroller for both hobby and commercial work is Silicon Laboratories' C8051 family, most notably C8051F530. There is an excellent free C compiler and assembler for the C8051 family called SDCC.
Summary: There are lots of options, but please don't let that overwhelm you. Just pick one and start learning with it. Microcontrollers are, really, surprisingly easy to master once you just decide to get going!
我的老板在没有任何经验的情况下,在一周内就掌握了使用 AVR 的基础知识。
My boss picked up the basics using AVR within a week without prior experience.
我建议使用AVR。 它已远远超过 PIC,成为一般爱好者项目首选的微控制器平台。 最值得注意的是,考虑 Arduino(和其他 *duino)平台,它以易于接口和流行的外形尺寸提供高端 AVR。
I would suggest AVR. It has far surpassed PIC as the microcontroller platform of choice for general hobbyist projects. Most notably, consider the Arduino (and other *duino) platform, which provides a high end AVR in an easy to interface and popular form factor.
与 PIC 相比,我更喜欢 AVR,我发现 PIC 的架构有点混乱。 这可能只是我的问题,如果您可以用高级语言(很可能是 C 的某种方言)编写,那么这不会给您带来麻烦。
由于您是微控制器的新手,我认为性能不会成为问题,因此相反我会寻找开发工具的可用性:原型板、IDE 和模拟/调试工具。 我个人非常喜欢 AVR Studio(Atmel 的免费开发环境)。
Jason 提到了 TI 的 MSP430,它确实是一款出色的控制器,特别是在功耗非常低的应用中。 但我不推荐新手使用它,因为配置有点麻烦。 (我记得用户手册中对振荡器的描述有 20 多页。)
I very much prefer the AVR over PIC, whose architecture I find a bit messy. This may be just me, and it won't trouble you if you can write in a high level language, most likely (some dialect of) C.
Since you're new to microcontrollers I presume performance will not be the issue, so instead I would look for availability of development tools: prototyping boards, IDE and simulation/debugging tools. Personally I liked AVR Studio (Atmel's free development environment) a lot.
Jason mentions the TI's MSP430, which is an excellent controller indeed, especially if you're in very low power applications. But I wouldn't recommend it for a newbie, since configuration is a bit cumbersome. (I recall that the description of the oscillator covered 20+ pages in the user manual.)
有些人评论了 PIC micro 的奇怪(并且 C 语言不友好)架构。 对于较小的 PIC 来说确实如此,但 16 位芯片(PIC24F、dsPIC30 等)具有非常清晰的架构,可以很好地与 C 语言配合使用。PIC24F
系列能够将引脚分配给功能(定时器、A/D、串行I/O)即时运行,使其更易于设计。 MPLAB 的调试和开发环境非常好。
Some people commented on the strange (and C unfriendly) architecture of the PIC micro. This is true of the smaller PICs, but the 16 bit chips (PIC24F, dsPIC30, etc) have very clear architectures that work very well with C.
The PIC24F line has the ability to assign pins to functions (timers, A/D, serial I/O) on the fly, making it a bit easier to design with. The MPLAB environment for debugging and development is quite nice.
我不明白arduino有什么大不了的,它会毁掉你理解实际发生的事情的机会。 我经常用AVR和PIC编程,基本上没有太大区别,我看不出有什么大惊小怪的。
然而,对于远离arduino的初学者来说,这可能很简单,但这就是陷阱,它没有给你硬件架构的概念,也不知道幕后发生了什么,而这些是初学者需要学习成为一名有效的程序员的东西。
当我还是个初学者时,我开始使用 ATmega32、20 美元的 USBasp 编程器、AVR Studio(免费)和 AVRDude(随 WinAVR 一起提供),并遵循 AVR Freaks 中的介绍教程。
这就是您所需要的,完成!
PS 如果你想真正学习如何对微控制器进行编程,并且有时间学习微控制器的汇编程序,那么你的 C 程序员能力将是刚开始使用 arduino 的人的 20 倍。
I don't understand what the big deal with arduino is, it will ruin your chance of ever understanding what is actually happening. I program with AVR's and PIC's regularly, basically there is not much difference, I can't see what the big fuss is all about.
However for a beginner stay away from arduino, it may be simple, but thats the trap, it gives you no concept of hardware architecture, and no idea what is happening behind the scenes, the stuff beginners need to learn to be an effective programmer.
When I was a beginner I started out with an ATmega32 a $20 USBasp programmer, AVR Studio (Free) and AVRDude (Comes with WinAVR) and followed the intro tutorials in AVR Freaks.
That is all you need, Done!!!
P.S. If you want to really learn how to program micros and have the time learn the assembler for your micro and you will be 20 times the C programmer than someone who started out using arduino.
我投票给 PIC,因为它提供了极其丰富的可用设备。 但我必须说,当我开始使用 PIC 时,它们几乎没有别的作用。 也许现在情况有所改变。
My vote goes to PIC for the extreme variety of devices availables. But I must say that when I started to use PICs, they was almost nothing else. Maybe now things are changed.
我投票给 TI 的 MSP430 系列。 我广泛使用过 PIC(也使用过一点 Atmel 芯片),到目前为止对我来说最重要的是一个良好的调试 IDE。 TI 在这方面做得非常好,他们的 C++ 编译器运行得非常好。 您可以花不到 100 美元购买评估板,包括 IDE + USB 调试器。 PIC 有更好的& 硬件外设更加多样化,但 MPLAB 就是一坨屎,唯一用于 PIC 的 C++ IDE 是 IAR 的,相当昂贵。 (超过 2000 美元)
I vote for TI's MSP430 series. I've used PICs extensively (also Atmel chips a little) and by far the most important thing to me is a good debugging IDE. TI has done a pretty good job on this, and their C++ compiler works really well. You can get going with an eval board for less than $100 including an IDE + USB-debugger. The PICs have better & more diverse hardware peripherals, but MPLAB is a piece of crap and the only C++ IDE for PICs is one by IAR which is rather expensive. (more than $2K)
我已经完成了一些 PIC 编程 - 主要是因为我喜欢芯片只需一两美元的想法。 然而,对于初学者来说,仅根据价格做出决定是不成熟的优化。
使用汇编程序进行编程是一种体验。 在让 LED 闪烁之前,您基本上必须了解大约 100 个概念。 (看门狗定时器、复位引脚、8 位计数器/溢出、延迟循环、十六进制、二进制、位屏蔽、中断、中断服务请求、IO 端口等)这一切都非常有教育意义 - 如此接近的感觉很棒到机器 - 但能够用 C 编写代码将隐藏一些复杂性,因此您可以专注于结果。 出于这个原因,我建议选择 AVR。 (我相信现在的价格更接近 PIC。)
另外:如果您有兴趣完成任务(并且不介意花费约 30 美元),请查看 arduino。 在我当地的电子商店里,一个卖这些东西的人说他正在向艺术系的学生出售大量的东西。 (它使用Processing项目中的IDE,并使用avr-gcc编译代码。)
更新:修复了Arduino运行解释代码的注释。 还更新了 Arduino 的大概价格。
I've done some PIC programming - mostly because I liked the idea the chip were only a dollar or two. However, for a beginner, making a decision solely on price is premature optimization.
Programming in assembler is an experience. You basically have to learn about 100 concepts before you can blink an LED. (Watchdog timer, reset pins, 8-bit counters/overflows, delay loops, hex, binary, bit-masking, interrupts, interrupt service requests, IO ports, etc.) It's all very educational - and a great feeling to get so close to the machine - but being able to code something in C will hide some of this complexity so you can focus on results. For this reason I would say go with the AVR. (And I believe the prices are now closer to PICs.)
Also: If you're interested in getting things done (and don't mind spending ~$30) check out the arduino. A guy selling them at my local electronics shop was saying he's selling tons of them to art students. (It uses the IDE from the Processing project, and compiles code with avr-gcc.)
Update: Fixed comment that Arduino runs interpreted code. Also updated the approx Arduino price.
我/我们选择PIC主要是因为同样的价格有更多的外围硬件。 更重要的是,您甚至找不到可比的 AVR。 不过,我确实选择了一个旧版免费版本(从 PIC18 开始,迁移到 dspic33)
IDE 是免费的,(C) 编译器在学生版本中是免费的(第一个月后禁用优化)。 入门级程序员也相当便宜。 如果您有大量中断、计数器和计时器,则您可能根本不需要优化。 直接从 Microchip 购买的程序员售价为 30 美元。
请注意,上述关于 AVR 更适合 HLL 开发的评论已经有点过时了,除非您真的选择 PIC12 和 16 等传统架构。
人们通常会编程更现代的 PIC18(8 位)和 16 位架构(24F、30F)和 dspic33(基于相同的主核心)在 C 语言中。16 位甚至使用 GCC。 现在也有基于 MIPS 的 32 位处理器,但它们在音频/视频处理领域更多地与 ARM 竞争。 奇怪的是,现代的往往比旧的便宜。 它们可能是通过更现代的工艺生产的,产量更高。
另请注意:同时 Microchip/PIC 收购了 Atmel/AVR,但我认为在最初几年,这不会对产品线产生太大影响。
我真的很期待将于今年夏天发布的支持 60MIPs 以太网的 16 位版本(据我所知,街头价格略高于 10 欧元)
I/we chose PIC mostly because there is more peripheral hardware for the same price. And more importantly, you can't even find comparable AVRs. I did choose one of the legacy free versions though (started with PIC18, migrated to dspic33)
The IDE is free, the (C) compiler is free in the student version (that disables optimization after the first month). Entry level programmers are fairly cheap too. If you have heaps of interrupts, counters and timers, there is a chance you won't need optimization at all. A programmer straight from Microchip is $30.
Note that the above remarks about AVR catering more to HLL development are slightly outdated unless you really go for the legacy architectures like PIC12 and 16.
One typically programs the more modern PIC18 (8-bit) and the 16-bit architectures (24F,30F and dspic33 which are based on the same principal core) in C. The 16-bitters even use GCC. There are also MIPS based 32-bitters now, but they rival more with ARM in the audio/video processing scene. Strangely enough, the modern ones are often cheaper than the old ones. Probably they are produced on in a more modern process that has higher yields.
Another note: meanwhile Microchip/PIC bought Atmel/AVR, but I assume that for the first few years that won't affect the productlines much.
I'm really looking forward to the 60MIPs ethernet enabled 16-bitter that is going to be released this summer (afaik streetprice just above EUR 10)
如果你只是想了解什么是MCU编程,从Arduino开始是个好主意。 它价格便宜,具有新手友好的 IDE(基于处理编程语言,其语法与 C 类似)。
但这并没有回答你的问题,因为尽管Arduino是基于AVR的,但你感觉不到现代IDE背后有一个AVR MCU。 :)
If you just want to know what is MCU programming, start from Arduino is a good idea. It's cheap, with a novice-friendly IDE (based on processing programming language, which has a similar syntax with C).
But this did not answer your quesiton, beacuse altough Arduino is based on AVR, you cannot feel there is an AVR MCU behind that modern IDE. :)
当我刚开始使用 PIC 时,我取得了更大的成功。 我试图从 Arduino 获得一个简单的入门套件,但如果不花费超过 100-200 美元镍币并将设置调暗,就无法获得一个好的基本套件。 花大约 40 美元从 PIC 购买了一个很棒的小型入门套件,里面有一切:IDE、编程器、带有用于演示和教程的内置电路的入门板。 一次购买。 此外,PIC 环境非常容易设置和运行。 不到一个小时我就玩完了。
I had much more success with PIC while I was just getting started. I tried to get a simple starter kit from Arduino and just couldn't get a good basic kit without spending more than $100-200 nickel and diming the setup together. Got a great little starter kit from PIC for about $40 and it has everything: IDE, programmer, starter board with built in circuitry for demos and tutorials. One purchase. Also, the PIC environment was very easy to get set up and working. I was playing with it within an hour.
我对微控制器的第一次体验是使用 OOPic-R。 它使我能够进行简单的机器人实验,而不必过多担心代码。 面向对象的编程流程使一切都可以快速运行并且易于编程。
最近,我尝试了另一种 PIC,即极其便宜的 PICAXE。 附带的编程接口使用起来非常轻松。 此外,要与 PICAXE 进行物理连接,您只需要一个对其进行编程的 RS-232 端口和芯片上的两个引脚(无需进行电平转换)。 我已将 PICAXE 嵌入到非常小的容器中(可用 SMD 和 DIP 芯片),并且效果非常好。
我没有在汇编中对微控制器进行编程的经验。 如果您想尝试一下,AVR 可能更合适,因为它的用户社区更大。
据我所知,使用 ATMEL 工具对 AVR 进行编程最便宜的方法是 ATMEL AVR ISP mkII,售价为 35 美元。 您可以花费 10-15 美元找到第三方程序员。
My first experience with microcontrollers was with an OOPic-R. It allowed me to make simple robotic experiments without worrying too much about the code. The object oriented programming flow makes everything work fast and is easy to program.
Recently, I tried another variety of PIC's, the dirt cheap PICAXE. The included programming interface is a breeze to work with. Also, to physically interface the PICAXE, you only need an RS-232 port to program it and two pins on the chip (no need to do level shifting). I've embedded the PICAXE in very small containers (SMD and DIP chips available) and it has worked quite well.
I have no experience with programming microcontrollers in assembly. If you want to try that, the AVR might be more suitable because of it's bigger user community.
As far as I know, the cheapest way to program an AVR using ATMEL's tools is the ATMEL AVR ISP mkII for 35$. You can find third-party programmers for 10-15$.
我开始使用摩托罗拉 M68HC11,它很简单。 我认为使用任何 8 位控制器都会获得相同的体验。
I started on a Motorola M68HC11, it was simple enough. I think you'll get about the same experience with any 8Bit controllers.
我会根据 C 交叉编译器的可用性做出选择。 在过去,这会让 AVR 成为选择。 我不确定现在是什么状态。
我用汇编程序编写了一个 PIC,但没什么乐趣。 C 在很多方面都更好。
I would make my choice based on availability of a C cross-compiler. In the past, that would make AVR the choice. I'm not sure what the status is now.
I've programmed a PIC in assembler, and it was not much fun. C is much nicer in many ways.
http://www.arduino.cc/
HTH
http://www.arduino.cc/
HTH
AVR 的最佳功能之一是 www.avrfreaks.net 论坛中的社区。 你会遇到一群经验丰富的电子工程师,他们愿意帮助新手上手。
On of the best features of AVR is the community in the forums at www.avrfreaks.net. You get a bunch of experienced electronics engineers hanging out, willing to help newbies to get going.
我想说的是,我发现 8051 微控制器是最简单的,Atmel 已经推出了具有如此多内置功能的微控制器……但人们仍然更喜欢使用 AVR……我会选择 8051 系列(如果觉得舒服的话)否则AVR的...
I would say that i fount the 8051 microcontroller the most easiest and Atmel has come up with microcontrollers with so many inbuilt functions .... but still people are more preferably using the AVR's... my hand would go up with the 8051 family ( if found comfortable ) else the AVR's ...
我喜欢AVR。 它易于编程且资源可用。 很少有像 arduino 这样的社区与之合作。
I love AVR. its easy to program and resources available. there are few community like arduino works with it.
关于 AVR 的优越性的更多讨论,在另一个 Stack Overflow 上:
http://embeddedgurus.com/stack-overflow/2009/04 /pic-stack-overflow/
Some more dicussion about the superiority of AVR, on the other Stack Overflow:
http://embeddedgurus.com/stack-overflow/2009/04/pic-stack-overflow/