➦ Figure 4. 440 Hz Music
Tone generator.
The 12V programming high-voltage Vpp
is generated by a
voltage regulator VR1
(317LZ) through a precision resistor divider
made from R1 and R2.
These two resistors
are specified at 1% tolerance to get accurate
voltage output.
Vpp is then
applied to the chip
RESET pin only after
power-up and chip reset. Transistor
pair Q1,Q2 acts as a switch to block
or allow Vpp to go through under
the control 4051 port pin P1.3.
When P1.3 is low, both Q1 and Q2
are cut off, so the pull-down resistor
R6 provides a way to reset the
ATtiny11 to ground. When P1.3 is
high, both Q1 and Q2 are turned on
and the 12 Vpp is applied to enable
the chip’s programming mode.
Ceramic resonator CR1 clocks the
4051 MCU, allowing it to operate at
9600 bps. LED1 indicates the programming status.
In order to make the programmer
more flexible, its power supply is
designed to be either 9 VAC or 12. 5
VDC. The bridge rectifier DF01 and
low voltage regulator VR2 (78L05)
provide +5V power for all chips.
Capacitors C2 and C4 are used to
smooth the DC output.
With 4K bytes of Flash memory,
the programmer can (barely) store
the code for all necessary operations: Blank Check, Erase Chip,
Read/Write flash, Read Signature
bytes, and Verify programming. The
lack of any extra room forces the
programmer to only accept binary
file input. It doesn’t accept Hex format files.
To ease this requirement, we
provide a software program named
HEX2BIN.EXE to let you convert
your Hex file into a binary file,
compatible with the programmer.
Now let’s see how to use this programmer to do something with
ATtiny11.
BLINKING LED
➥ Figure 5. Third Example Circuit.
The simplest application to
demonstrate MCU programming is
LED ON/OFF control. Figure 3 shows
the actual circuit, and Listing 1 is
the AVR assembly language source
code.
After power-up and completing
the chip reset, the LED connected to
PB0 (pin 5) is alternately driven high
and low, for a half second each, caus-
➦ Listing 1. Single and Double Blinking
LED program.
; LED1N2.ASM: Single/Double Blinking LED program
; 1 Hz blinking LED driven by Tiny11/12 AVR working at 1 MHz
; LED is connected to AVR PortB Bit_0 (Pin 5 for ATtiny11/12)
; Double blinking LED is generated by Low-level trigger INT0
; at PortB Bit-1 (Pin 6 for ATtiny11/12)
.include “TN11def.inc”
.cseg
.org 0
; Port definitions here
rjmp
rjmp
RESET
INT0_LED2
; INT0 is used to cause double-blinking LED
RESET:
ldi
out
ldi
out
ldi
out
sbi
r16, $80
SREG, r16 ; Enable any Interrupt
r16, $40
GIMSK, r16 ; Enable INT0
r16, $00
MCUCR, r16 ; INT0 = Low-Level triggered
DDRB, 0 ; config DDRB bit-0 as output for LED
LED1:
cbi PORTB, 0 ; LED=ON
RCALL DLhalfS
sbi PORTB, 0 ; LED=OFF
RCALL DLhalfS
rjmp LED1 ; repeat again
;——————————————————————————————————————————————
;the delay = 1/2 sec at 1 MHz
DLhalfS:
LDI
calop:
R20, 3
LDI
R19, 248
malop:
LDI
R18, 248
LOOP1:
DEC
R18
continued ...
February 2006 63