日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

Programming The ATtiny85(譯)

 新用戶5228KeDY 2021-10-10

Programming The ATtiny85(譯)

It Packs A Punch!

說明:本文來自https:///projects/programming_the_attiny85,篇名大概能譯作《一文搞定Attiny85編程》。

起因是這樣的,這段時間以來,一直在琢磨用Attiny13A/Attiny85做出來最小的頻閃光源?;蛟S是做事習慣的緣故——我比較喜歡做事從最困難的做起來,這樣余下的就都是滿滿的自己對自己的鼓勵了——選擇了最開始的研究對象,是Attiny13A。結果很多教程和資料都因為年代久遠而無法配置齊全環(huán)境,有些需要下載的東西,各種原因不能達成,但最終總算是燒錄成功,實驗也做成了。輪到Attiny85的時候,搜索了幾篇文章就起手,沒有任何的波折就結束了。

后來發(fā)現(xiàn)這一篇文章也在,雖然沒有使用它,但是異常簡單地配置、燒錄等等,似乎仍有它的價值,就決定譯了它。我是英語特差的那類人,擔心誤譯了文字,故英漢同時放在一起(雖然不少機器翻譯很容易操作,然而我仍不喜歡看它們)。

The ATtiny85 IC is one of the smallest microcontrollers you can get (it’s not the smallest Atmel microcontroller – the ATtiny10 has only six pins!), which makes it ideal for those applications where space is at a premium.若是你制作的某個小玩意兒空間有限時,Attiny85大概是你可能使用的最小的IC了(它不是Atmel芯片里就小的,Attiny10比它更小,只有6個引腳!)

HOW IT WORKS怎么做

Unlike an Arduino Uno, an ATtiny85 does not normally have a bootloader. This is a small program that sits in the flash memory, and is what actually runs when you ?rst power it up. You might notice that the onboard LED on an Uno blinks a few times, no matter what sketch is loaded – this is the bootloader letting you know it is there. The bootloader listens in the ?rst second of power-up, searching for a certain sequence of data on the serial port, and if it is detected it goes into sketch upload mode. Without this handy piece of code, we need another way of putting our program onto the chip, and as noted earlier, we can use ISP. Another advantage of not using a bootloader is that the bootloader takes up precious flash program space, and with a small microcontroller like the ATtiny85 – which has just 8kB of flash – anything saved will help.Attiny85與Arduino Uno不同之處,是ATtiny85沒有Bootloader。有Bootloader的好處是可以直接在串口上傳我們的程序,沒有Bootloader則需要另外的方式燒錄。但是Bootloader會占用一定的Attiny85的閃存空間,畢竟這個小芯片只有8 kB。

To do a basic test of ISP programming an ATtiny85 with an Uno, you will need an Uno main board, an ATtiny85 IC, a breadboard and some jumper leads. An IC socket can help too. 要對ATtiny85進行ISP編程,需要有Arduino UNO板、ATtiny85芯片、面包板和跳線,有個IC座也會有用。

The first step is to configure the Arduino IDE to work with the ATtiny85, as this is not included by default. The following assumes you are using at least version 1.6.4, as this is when the Boards Manager was introduced. 第一步要做的是配置IDE使之能收拾Attiny85,確保IDE為1.6.4以上版本,因為開發(fā)板管理器里面的介紹就這么說的。

Open the Preferences window from File>Preferences and if there are existing entries, add a comma at the end, then add: 去首選項里面填入下面的網(wǎng)址,如果已經(jīng)有其他的,就用逗號隔開(ATtiny85自動由IDE配置開發(fā)板支持庫,多已不能用,唯此文介紹竟然一次性安裝成功,這表明這篇文章介紹的東西還是比較有價值的。是以譯之。)

https://raw./damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json

Then go to Tools>Board>Boards Manager, search for “attiny” and install the option that looks like this:然后到開發(fā)板管理器里安裝David A.Mellis這個attiny庫,目前是1.0.2。

After this, the Tools>Board menu should give you a few ATtiny options.之后可以選擇ATtinyX5系列的開發(fā)板,并能進行簡單幾個設置(前面我使用的不少ATtiny85板卡支持都要進行很麻煩的設置,只有這具設置是相對簡單的,對于常用的情況,似乎麻煩的設置沒有必要)。

Note that there are a few sub-menu options, so make sure (when working with the ATtiny85) that the options selected are “ATtiny85” and “internal 8MHz oscillator”.注意選擇ATtiny85和內部8M振蕩器。Be careful not to choose an external oscillator mode, as this might cause the ATtiny85 to appear “bricked”, as it will be expecting an external clock source, which probably isn’t connected.不要選擇使用外部晶振,否則在不連接外部晶振時,ATtiny85看起來象是變磚了。

Before building, open the ArduinoISP sketch from File>Examples>11.ArduinoISP>ArduinoISP, and upload it to the Uno (remembering to select Uno again for now), then connect everything up as shown, noting that pin 1 on the ATtiny85 is the top left corner with the notch to the right. If you aren’t familiar with IC pin numbering, the numbers increase anti-clockwise from pin 1.燒錄之前,打開ArduinoISP.ino燒錄到UNO板,然后連接UNO引腳和ATtiny85引腳。ATtiny85引腳順序是1號位于左上角,然后逆時針依次2至8.

The connections are as follows:按以下方式連接UNO和ATtiny85的引腳

UNO PIN
ATTINY85 PIN
5V
8
GND
4
D10
1
D11
5
D12
6
D13
7

There is also an extra wire on the Uno, going from RESET to the top right pin on the ISP header – this holds the RESET pin high and keeps the Uno from resetting and being accidentally reprogrammed instead of passing on its programming instructions to the target microcontroller (the ATtiny85). 有一條額外的連線從UNO的RESET到ISP接頭的右上角引腳——這使RESET引腳始終為高電平,防止Uno復位和意外重新編程,這條線并不是用來把給ATtiny85編程的。

I’ve also connected an LED between pin 2 (which is confusingly called “pin 3” under the Arduino IDE) and ground via a resistor. With this, we can test basic sketches such as “Blink”.注意面包板上的LED,它串聯(lián)了一個電阻接在了ATtiny85的2和4即Arduino的D3和GND。接這些小物件,是為了一會測試Blink程序的。

下圖是我補充的:

Brand new ATtiny85 ICs are set to have a 1MHz internal oscillator, and so they will appear to run slow if the sketch expects an 8MHz internal oscillator. To ?x this, we make sure we have the ATtiny with 8MHz internal oscillator selected from the Tools>Board Menu, select “Arduino as ISP” as the programmer from the Tools>Programmer menu (note: there may be a similar sounding but different programmer called “ArduinoISP”), and that the Uno’s serial port is selected in the Tools>Port menu.全新的ATtiny85頻率被設定為1M,這會使8M頻率的ino文件運行起來顯得慢一些。為了修正這個問題,在把Arduino板設置成燒錄器的同時,要設置ATtiny85為內部振蕩8MHz。

Click Tools>Burn Bootloader. I did mention before that we aren’t actually using a bootloader, but this is how the Arduino IDE can also set the con?guration fuses on the ATtiny85.然后在工具里選擇燒錄引導程序。

You should see a “Done burning Bootloader” message in the Arduino IDE. If this is the case, the setup is probably correct, and you can open up the Blink sketch and change the references from pin 13 to pin 3.這個時候,在IDE里會看到引導程序燒錄成功的提示信息,之后打開Blink,把里面的LED_BUILTIN改成3。

void setup() {
  pinMode(3, OUTPUT);
}
void loop() { loop() {
  digitalWrite(3, HIGH);
  delay(1000);
  digitalWrite(3, LOW);
  delay(1000);
}

Finally, click Upload (Ctrl-U or Sketch>Upload). If the LED starts flashing on for a second and off for a second, then you have a working ATtiny85 programmer on a breadboard.然后燒錄到ATtiny85。If you get messages like “Programmer not found”, check that you have the correct programmer selected, that the serial port is correct, and that the ArduinoISP sketch is properly loaded onto the Uno (you might need to temporarily disconnect the wire on RESET to allow the sketch to be uploaded to the Uno).注意使用用編程器來燒錄。如果提示編程器找不到,檢查UNO是否正確連接,必要是需要RESET一下。

If you get a message like “Wrong microcontroller found”, then check which “board” has been selected (e.g., you might have an ATtiny25 selected by default instead of ATtiny85). If the LED isn’t flashing at the right speed, then you might have an oscillator speed mismatch between the IDE and IC, so reselect the right speed from the Tools menu and select “burn bootloader” before uploading the sketch again.如果提示微控制器不正確,看看設置;如果LED閃爍速度不正常,檢查燒錄時的振蕩頻率是否正確。

如果需要,可以使用Shield或者IC鎖緊座,參考一些現(xiàn)成的7805穩(wěn)壓電路、加上濾尖峰、防反接等,焊在電路板上,或者把ATtiny85改成328P,改一改電路,自制Arduino也是可能的。

    轉藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多