<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>atmel on irq5 test</title><link>https://irq5-7854a1fdb9f4.pages.dev/tag/atmel/</link><description>Recent content in atmel on irq5 test</description><language>en-us</language><lastBuildDate>Sat, 09 Sep 2017 12:47:00 +0000</lastBuildDate><atom:link href="https://irq5-7854a1fdb9f4.pages.dev/tag/atmel/feed/" rel="self" type="application/rss+xml"/><item><title>Writing Code for the ATtiny10</title><link>https://irq5-7854a1fdb9f4.pages.dev/2017/09/writing-code-for-the-attiny10/</link><pubDate>Sat, 09 Sep 2017 12:47:00 +0000</pubDate><guid>https://irq5-7854a1fdb9f4.pages.dev/2017/09/writing-code-for-the-attiny10/</guid><description>&lt;p>I previously wrote about the hardware aspects of
&lt;a href=https://irq5-7854a1fdb9f4.pages.dev/2010/07/programming-the-attiny10/ rel=noopener>getting your code into an ATtiny10&lt;/a> some 7 years ago
(wow that was &lt;em>realllyy&lt;/em> a long time ago!).&lt;/p>&lt;p>Now, avrdude is at version 6.3 and
the TPI bitbang implementation has already been integrated in.
The upstream avr-gcc (and avr-libc) also have proper support for ATtiny10s now.
These software components are bundled with most distributions,
including the &lt;a href=https://www.arduino.cc/en/Main/Software rel=noopener target=_blank class=external>Arduino IDE&lt;/a>,
making it easily accessible for anyone.
Previously a fully integrated and working toolchain only came from Atmel and it was behind a registration page.&lt;/p>&lt;p>The price of the ATtiny10 has also dropped by a lot.
When I first bought this microcontroller in 2010,
element14 carried it for $1.85 in single quantities.
Now, they are only $0.56 each.&lt;/p>&lt;p>I thought I&amp;rsquo;d write up a short post about writing and compiling code for it.&lt;/p>&lt;p>&lt;picture>&lt;source srcset=/posts/2017/img/attiny10-closeup.jpg.webp type=image/webp>&lt;img src=https://irq5-7854a1fdb9f4.pages.dev/posts/2017/img/attiny10-closeup.jpg alt="ATtiny10 on a prototyping board" width=1023 height=682>&lt;/picture>&lt;/p>&lt;p>&lt;a href="https://irq5-7854a1fdb9f4.pages.dev/2017/09/writing-code-for-the-attiny10/#more">Continue reading…&lt;/a>&lt;/p></description></item><item><title>Making USBasp Chinese Clones Usable</title><link>https://irq5-7854a1fdb9f4.pages.dev/2017/07/making-usbasp-chinese-clones-usable/</link><pubDate>Tue, 25 Jul 2017 00:06:00 +0000</pubDate><guid>https://irq5-7854a1fdb9f4.pages.dev/2017/07/making-usbasp-chinese-clones-usable/</guid><description>&lt;p>I don&amp;rsquo;t have any dedicated programmers.
I have been programming Atmel chips
&lt;a href=https://irq5-7854a1fdb9f4.pages.dev/2010/07/programming-the-attiny10/ rel=noopener>using the USB-to-serial bitbang method&lt;/a>.&lt;/p>&lt;p>Recently, I thought I&amp;rsquo;d get one because doing a re-programming cycle is taking
quite a bit of time (a disadvantage of serial port bitbanging).&lt;/p>&lt;p>A popular one on Aliexpress seems to be
&lt;a href=https://www.aliexpress.com/item/1pcs-Free-shipping-USB-ISP-USBasp-USBisp-Programmer-for-51-ATMEL-AVR-download-support-Win-7/1289376766.html rel=noopener target=_blank class=external>this &amp;ldquo;USB ISP&amp;rdquo; one&lt;/a>, so I bought one.
I chose this one because it has a nice aluminium case, and a pinout diagram
imprinted on the case, which is handy.
After having so many one-off projects with bare PCBs collecting dust,
I now appreciate the importance of having projects in their own box or case.&lt;/p>&lt;p>&lt;picture>&lt;img src=https://c1.staticflickr.com/5/4324/35866155142_0bf2674c3e_b.jpg alt="USB ISP programmer with aluminium case">&lt;/picture>&lt;/p>&lt;p>While it has &amp;ldquo;USBasp&amp;rdquo; in the item name, it turns out that this was &lt;strong>not a USBasp device&lt;/strong>,
and getting it to work like one takes some effort.&lt;/p>&lt;p>It identifies itself as a &lt;em>zhifengsoft&lt;/em> HID device when I plug it into Linux:&lt;/p>&lt;div class=highlight role=region aria-label="code block" translate=no>&lt;pre tabindex=0 class=chroma>&lt;code class=language-fallback data-lang=fallback>&lt;span class=line>&lt;span class=cl>[705621.968025] usb 3-1: new low-speed USB device number 3 using ohci-platform
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>[705622.199065] usb 3-1: New USB device found, idVendor=03eb, idProduct=c8b4
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>[705622.205939] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>[705622.213194] usb 3-1: Product: USBHID
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>[705622.216876] usb 3-1: Manufacturer: zhifengsoft&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>avrdude&lt;/code> does not recognize the device,
even after creating an entry with the corresponding vendor/product ID.
This particular device was designed to work with their Windows-based UI called
&lt;a href=http://www.electrodragon.com/w/ProgISP rel=noopener target=_blank class=external>ProgISP&lt;/a>
and &lt;a href=http://www.avrfreaks.net/forum/how-use-usbasp#comment-1459441 rel=noopener target=_blank class=external>will not work with avrdude&lt;/a>.&lt;/p>&lt;p>And apparently you can&amp;rsquo;t just take the USBasp firmware and flash it into
this device, because the circuit is somewhat different.&lt;/p>&lt;p>After some research based on the PCB markings, I found these sites that talk about them:&lt;/p>&lt;ul>&lt;li>&lt;a href="https://www.sciencetronics.com/greenphotons/?p=938" rel=noopener target=_blank class=external>GreenPhotons: Hacking an AVR programmer&lt;/a>&lt;/li>&lt;li>&lt;a href="https://www.sciencetronics.com/greenphotons/?p=1937" rel=noopener target=_blank class=external>GreenPhotons: Hacking an AVR programmer II&lt;/a>&lt;/li>&lt;li>&lt;a href="http://wiki.efihacks.com/index.php?title=USBasp_Experiences" rel=noopener target=_blank class=external>USBasp Experiences - efiHacks Wiki&lt;/a>&lt;/li>&lt;/ul>&lt;h1 id=disassembly>Disassembly&lt;/h1>&lt;p>Disassembling the device is simple.
While grabbing the side of the case, firmly push the USB connector inwards
and the board should slide out the other end.
You can then gently pull the board out by the IDC connector.&lt;/p>&lt;p>&lt;picture>&lt;img src=https://c1.staticflickr.com/5/4308/35964033316_b5385eed09_b.jpg alt="Disassembly how-to photo">&lt;/picture>&lt;/p>&lt;p>The programmer seems to be based off of the popular &lt;a href=http://www.fischl.de/usbasp/ rel=noopener target=_blank class=external>USBasp programmer&lt;/a>,
but modified somewhat (to what end I&amp;rsquo;m not sure).
It lacks some features offered by other USBasp programmers,
like the ability to control the target&amp;rsquo;s clock,
or to use 3.3V for certain targets.
But at $2 with a nice aluminium case, what more can you ask for?&lt;/p>&lt;p>It&amp;rsquo;s powered by an ATmega88 (I read that older versions were based on ATmega8).
The markings on the board indicate that this is a &lt;code>MX-USBISP-V4.00&lt;/code>.
You can ignore tHe date because it was never updated;
the older V3.02 also has the same date.
While the &lt;em>GreenPhotons&lt;/em> blog was talking about V3.00,
I have verified that this version suffers from the same issue.&lt;/p>&lt;p>&lt;picture>&lt;img src=https://c1.staticflickr.com/5/4310/36005584165_a81de0f13c_b.jpg loading=lazy alt="USBISP programmer, with aluminium case">&lt;/picture>&lt;/p>&lt;p>&lt;picture>&lt;img src=https://c1.staticflickr.com/5/4291/35964039616_074efac6af_b.jpg loading=lazy alt="USPISP PCB rear">&lt;/picture>&lt;/p>&lt;p>Note that there are provisions on the PCB to add a voltage regulator,
and the PCB link marked &amp;ldquo;C&amp;rdquo; can be cut to separate USB power from the
rest of the system. Link &amp;ldquo;D&amp;rdquo; can be cut if you wish to disable target power.
However, none of these options were used.&lt;/p>&lt;p>The crucial difference with this clone
is that the USB &lt;code>D-&lt;/code> pin is additionally connected to &lt;code>PD3&lt;/code>,
shown here highlighted in blue:&lt;/p>&lt;p>&lt;picture>&lt;source srcset=/posts/2017/img/zhifengsoft-schematic-diff.png.webp type=image/webp>&lt;img src=https://irq5-7854a1fdb9f4.pages.dev/posts/2017/img/zhifengsoft-schematic-diff.png loading=lazy alt="Clone difference in schematic view" width=502 height=336>&lt;/picture>&lt;/p>&lt;p>However, in the USBasp&amp;rsquo;s &lt;code>main()&lt;/code> function, &lt;code>PORTD&lt;/code>&amp;rsquo;s
data direction register was initialized like so:&lt;/p>&lt;div class=highlight role=region aria-label="code block" translate=no>&lt;pre tabindex=0 class=chroma>&lt;code class=language-c data-lang=c>&lt;span class=line>&lt;span class=cl> &lt;span class=cm translate>/* all outputs except PD2 = INT0 */&lt;/span>
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl> &lt;span class=n>DDRD&lt;/span> &lt;span class=o>=&lt;/span> &lt;span class=o>~&lt;/span>&lt;span class=p>(&lt;/span>&lt;span class=mi>1&lt;/span> &lt;span class=o>&amp;lt;&amp;lt;&lt;/span> &lt;span class=mi>2&lt;/span>&lt;span class=p>);&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>This causes the USB &lt;code>D-&lt;/code> line to be actively driven from &lt;code>PD3&lt;/code>,
thereby impeding communication to/from the USB host.&lt;/p>&lt;p>The rest of this post will talk about (1) correcting this problem in USBasp,
and (2) uploading the firmware into your &lt;em>zhifengsoft&lt;/em> programmer.&lt;/p>&lt;p>&lt;a href="https://irq5-7854a1fdb9f4.pages.dev/2017/07/making-usbasp-chinese-clones-usable/#more">Continue reading…&lt;/a>&lt;/p></description></item><item><title>DIY Optical Slave Flash</title><link>https://irq5-7854a1fdb9f4.pages.dev/2012/03/diy-optical-slave-flash/</link><pubDate>Sat, 24 Mar 2012 01:13:00 +0000</pubDate><guid>https://irq5-7854a1fdb9f4.pages.dev/2012/03/diy-optical-slave-flash/</guid><description>&lt;p>I found a couple of old disposable cameras in storage that I played around with 15 years ago, shorting the caps to make a loud bang, wiring up the flash trigger to a remote-controlled relay kit I had assembled. I thought I&amp;rsquo;d do something useful with them.&lt;/p>&lt;p>I decided to turn them into optical slave flashes, since on-camera flashes are not very flexible. I was thinking of a way to detect the camera flash so that the slave could be fired, maybe using an LDR with the ADC to detect an increase in light intensity? It turns out there&amp;rsquo;s an even easier way to do this - with an infrared sensor. Apparently when flash tubes are fired, they give off infrared which can be detected more reliably than light intensity changes. When I read about this, I tested it out with a simple Arduino sketch and it works as advertised.&lt;/p>&lt;p>Disposable cameras usually have metal contacts that are placed near the shutter mechanism. When the shutter opens, the contacts are closed and if the flash was charged it would fire. To control the flash firing, I replaced the contacts with an SCR.&lt;/p>&lt;p>&lt;picture>&lt;source srcset=/posts/2012/img/flash-scr.jpg.webp type=image/webp>&lt;img src=https://irq5-7854a1fdb9f4.pages.dev/posts/2012/img/flash-scr.jpg alt width=499 height=395>&lt;/picture>&lt;/p>&lt;p>&lt;a href="https://irq5-7854a1fdb9f4.pages.dev/2012/03/diy-optical-slave-flash/#more">Continue reading…&lt;/a>&lt;/p></description></item><item><title>My First Arduino</title><link>https://irq5-7854a1fdb9f4.pages.dev/2011/10/my-first-arduino/</link><pubDate>Sat, 08 Oct 2011 01:02:00 +0000</pubDate><guid>https://irq5-7854a1fdb9f4.pages.dev/2011/10/my-first-arduino/</guid><description>I finally bought myself an Arduino Uno this week.
&amp;ldquo;Wait a minute&amp;mldr; then what have you been using?&amp;rdquo; I hear you ask. Previously I had access to an Arduino Duemilanove, and used it to burn the Optiboot bootloader onto an ATmega168 that I had. The Duemilanove board used an FTDI chip which had additional pins brought out to an unsoldered header marked as X3. Following this guide by Kimio Kosaka, I downloaded the precompiled avrdude for Windows and used it to program the ATmega168 via the X3 header.&lt;p>&lt;a href="https://irq5-7854a1fdb9f4.pages.dev/2011/10/my-first-arduino/#more">Continue reading…&lt;/a>&lt;/p></description></item><item><title>Reducing power usage on the iCufflinks' ATtiny4</title><link>https://irq5-7854a1fdb9f4.pages.dev/2011/08/reducing-power-usage-on-the-icufflinks-attiny4/</link><pubDate>Sat, 27 Aug 2011 14:24:00 +0000</pubDate><guid>https://irq5-7854a1fdb9f4.pages.dev/2011/08/reducing-power-usage-on-the-icufflinks-attiny4/</guid><description>I came across this very nice article which documents steps taken to reduce the power usage on the ATtiny4 used in the iCufflinks.
The process managed to shave off about 315 μA, which boosts battery life quite a bit:
The overall effect this has on the product is that the 24 hour time between battery changes can be upped to 38 hours. That is a pretty good power savings for the day.&lt;p>&lt;a href="https://irq5-7854a1fdb9f4.pages.dev/2011/08/reducing-power-usage-on-the-icufflinks-attiny4/#more">Continue reading…&lt;/a>&lt;/p></description></item><item><title>Programming the ATtiny10</title><link>https://irq5-7854a1fdb9f4.pages.dev/2010/07/programming-the-attiny10/</link><pubDate>Thu, 15 Jul 2010 22:03:00 +0000</pubDate><guid>https://irq5-7854a1fdb9f4.pages.dev/2010/07/programming-the-attiny10/</guid><description>&lt;p>Recently I wanted to use a really tiny, low pin-count microcontroller for a project, so I decided to buy a few &lt;strong>Atmel ATtiny10&lt;/strong> to experiment with.&lt;/p>&lt;p>To get it working, I would need a compiler and a programmer. I like working with Atmel chips because they have cross-platform development tools. The Arduino IDE that I&amp;rsquo;ve been using comes with &lt;em>avr-gcc&lt;/em> and &lt;em>avrdude&lt;/em>, both of which are really awesome open source tools for compiling and uploading code to the microcontrollers. If you just want the tools without the Arduino IDE, you can get the WinAVR package.&lt;/p>&lt;p>However both of these tools do not work with the ATtiny10 yet. I do not expect a C compiler, but even the GNU assembler that comes with avr-gcc still doesn&amp;rsquo;t support this chip. avrdude recently added support for uploading to the ATtiny10, but only through the STK or AVRISP programmer, which I didn&amp;rsquo;t want to fork out money to buy.&lt;/p>&lt;p>&lt;a href="https://irq5-7854a1fdb9f4.pages.dev/2010/07/programming-the-attiny10/#more">Continue reading…&lt;/a>&lt;/p></description></item></channel></rss>