Today was the first really sunny day this spring in Uppsala. Reaching 25°C I spent a large part of the day on my balcony where I was visited by a special guest:
This rose chafer was elected the insect of the year 2000 in Germany where it is rare and protected. On my balcony here in Uppsala I see them every once in a while.
Later today I finally decided to get acquainted with ATMEL’s AVR family of microcontrollers. I had planned to learn something about microcontrollers for many years. First I purchased some PIC 16C84 which I never used and which are well stored away in a box. Later I even bought an ATMEL STK500 starter kit through eBay – just for it to sit on my shelf for I don’t know how many years. But today the bug got me.
I took down the slightly dusted box, unpacked the pristine circuit board, grabbed a 12V wall plug from another box and downloaded the recent version of the ATMEL AVRStudio and WinAVR. Then I connected the circuit board to the 12V supply and through an USB/RS232 converter to my computer and fired it up for the very first time.What a surprise! Everything worked at once! Well the USB/RS232 converter actually wasn’t fully cooperative. It is one of these little gadgets where you actually have to read the manual first in order to see that you have to first install the driver and then connect the thing to the USB port. I still wonder why some manufacturers choose this procedure instead of having Windows first discover the new hardware by itself…
And yes, all this is done from my MS Windows XP computer – so far the ATMEL AVRStudio only comes in a Windows version. But it seamlessly integrated with the open-source C-compiler for the AVR, which makes things very easy…
Then it was time to write my first ever microcontroller code. This one was in assembler, because I followed ATMEL’s Novice’s Guide to AVR Development. Of course the example program in this guide is very rudimentary and getting it into the ATMEGA8535 was simple, but because of the high speed of a real device in comparison to the simulation you don’t actually see the binary counting on the LEDs. So I made up my first own AVR program:
; UZ 2010-05-15
.include "m8535def.inc"
.def Temp = R16
.def Cnt1 = R17
.def Cnt2 = R18
.org 0x0000
rjmp RESET
RESET:
ldi Temp, 0xFF
ldi Cnt1, 0xFF
ldi Cnt2, 0xFF
out DDRB, Temp
LOOP1:
out PORTB, Temp
dec Temp
LOOP2:
LOOP3:
dec Cnt2
brne LOOP3
dec Cnt1
brne LOOP2
rjmp Loop1
And by now it has been running for hours!
Now that I have been bitten by the bug: expect more microcontroller projects in the future!
Oh, and by the way: the STK500 also features green LEDs. The status display is equipped with a red/green smd LED, which in the photo to the right clearly emits green photons!
[…] And for that I have been using some different types of programmers by now: starting with the good old STK500, to different versions of USBasp clones from Chinese sellers on […]