What
the hell is an ATMEL AVR?
Atmel's
AVR microcontrollers have a RISC core running single cycle instructions
and a well- defined I/O structure that limits the need for external
components. Internal oscillators, timers, UART, SPI, pull-up resistors,
pulse width modulation, ADC, analog comparator and watch dog timers
are some of the features you will find in AVR devices.
AVR instructions
are tuned to decrease the size of the program whether the code is written
in C or Assembly. With on-chip in-system programmable Flash and EEPROM,
the AVR is a perfect choice in order to optimize cost and get product
to the market quickly.
The chips
allow the program memory to be reprogrammed in-system through a SPI
serial interface. This provides a highly flexible and cost effective
solution to many embedded control applications.
|
What
the hell is an AT89S8252?
The AT89S8252
is a 80C51 compatible 8-bit single chip microcontroller with 8k internal
code and
2k data flash on chip. The chip allows the program memory to be reprogrammed
in-system
through a SPI serial interface. This provides a highly flexible and
cost effective
solution to many embedded control applications.
The chip has the following features:
- 80C51-compatible core (you'll find a lot of tools for this device)
- in-system programmable by this tool
- 8k protectable downloadable flash
- 2k EEPROM
- 256 Bytes RAM
- 32 I/O lines
- three 16 bit timer/counters
- a six-level interrupt architecture with nine interrupt sources
- a full duplex serial interface
- pretty cheap (less than $10 I guess)
- ... and many more ...
|
|
|
|
How
to build the programming interface
All
you need to program the device is this program and five wires from
your PC to the target board. There is no additional hardware
(like a programmer) required.
Your code needs to be in raw BIN format.
(if your compiler generates HEX-Files, use a "HEX to BIN" converter.
I added a HEX2BIN which I found in the internet for free)
ISP - programming
cable
Connect
PC and chip as follows:
Printer
Port
|
ATMEL
|
Pin:6
(D4)
|
RESET
|
Pin:7
(D5)
|
MOSI
|
Pin:8
(D6)
|
SCK
|
Pin:10
(ACK)
|
MISO
|
Pin:20
(GND)
|
GND
|
The cable should not be longer than 2m to avoid electrical reflections.
Don't
forget to:
|
ATMEL
AVR
- connect
a xtal and two capacitors (22pF) (See datasheed)
- use 5V
power supply
- connect
a resistor from RESET to VCC
- connect
an capacitor (100nF) between Vcc and Ground as close to the chip as
possible --> avoid long lines
- avoid
differences in ground potential between your target hardware and the
PC
- check
what is connected to the portpins MOSI, MISO and SCK. These pins are
used to program the
chip. Your target board could response to these signals if something
is connected to these pins.
|
AT89S8252
- strap
/EA (Pin 31 uC) to Vcc to operate from internal flash-memory
- connect
a xtal (4 - 24MHz) and two capacitors (22pF) (See datasheed)
- use 5V
power supply
- connect
a capacitor and a resistor to RESET to get a power on reset
- connect
pullups to P0 if this port is used as output
- connect
an capacitor (100nF) between Vcc and Ground as close to the chip as
possible --> avoid long lines
- avoid
differences in ground potential between your target hardware and the
PC
- check
what is connected to the portpins P1.5, P1.6 and P1.7. These pins are
used to program the
chip. Your target board could response to these signals if something
is connected to these pins.
|
Test
mode
Start
the test mode with the parameters: /LPTn /TEST
In the test mode the logical states of the programming cable can
be tested.
Type 1,2 or 3 to change the state of the output lines.
High should be between 4 and 5 volts, Low 0 to 0,5 volts.
If the high level is between 2 and 4 Volts, connect 10k resistors
from the output lines to Vcc to pull up the level. |
In
case of problems
If
you have problems programming the device:
-
check 5V power supply
- use the /TEST mode to check the programming interface
- connect 10k resitors from MOSI, MISO and SCK to Vcc (sometimes
nescessary for notebooks)
- check if you use the right printer port
- try programming in DOS mode if you use windows, sometimes a
driver locks the port
- check the xtal circuit
- try /SLOW mode |
|
ATMEL
AVR
How
to use the software:
Download
the program and extract the ZIP-file.
Connect the micrcontroller to your PC and start the program with the
following parameters:
Usage: ISP_AVR.EXE /LPTn [/ERASE] [/LOCK] [/SLOW] [/READ] [/DATA]
[/BO] [/TEST] <file>
description:
- /LPTn
use LPT1, LPT2 or LPT3 to select the printer port
- /ERASE
Erase code and data memory before writing
- /LOCK
Set lock bits after writing
- /SLOW
Use slower data transfer (in case of problems)
- /READ
Read code/data memory
- /DATA
Program/Read the 2k data memory instead of code memory
-
/TEST Start hardware test mode
- /BO
programs the brown-out fuses (if avalible). (4V and Reset 256ms +16k
* ck) (see data sheed)
Example 1:
Write the file PROGRAM.BIN into the CODE memory and erase the chip first.
The Programmer is connected to LPT1.
ISP_AVR.EXE /LPT1 /ERASE PROGRAM.BIN
Example 2:
Write the file DAT1.BIN into the DATA memory and do not erase the chip.
The Programmer is connected to LPT1.
ISP_AVR.EXE /LPT1 /DATA DAT1.BIN
Example 3:
Read the DATA memory and write to file CODE.BIN
The Programmer is connected to LPT2.
ISP_AVR.EXE /LPT2 /READ CODE.BIN
Example 4:
Read the DATA memory and write to file DAT2.BIN
The Programmer is connected to LPT2.
ISP_AVR.EXE /LPT2 /READ /DATA DAT2.BIN
|
AT89S8252
How
to use the software:
Download
the program and extract the ZIP-file.
Connect the micrcontroller to your PC and start the program with the
following parameters:
Usage: ISP_HB.EXE /LPTn [/ERASE] [/LOCK] [/SLOW] [/READ] [/DATA]
[/TEST] <file>
description:
-
/LPTn use LPT1, LPT2 or LPT3 to select the printer port
- /ERASE
Erase code and data memory before writing
- /LOCK
Set lock bits after writing
- /SLOW
Use slower data transfer (in case of problems)
- /READ
Read code/data memory
- /DATA
Program/Read the 2k data memory instead of code memory
- /TEST
Start hardware test mode
Example 1:
Write the file PROGRAM.BIN into the CODE memory and erase the chip first.
The Programmer is connected to LPT1.
ISP_HB.EXE /LPT1 /ERASE PROGRAM.BIN
Example 2:
Write the file DAT1.BIN into the DATA memory and do not erase the chip.
The Programmer is connected to LPT1.
ISP_HB.EXE /LPT1 /DATA DAT1.BIN
Example 3:
Read the DATA memory and write to file CODE.BIN
The Programmer is connected to LPT2.
ISP_HB.EXE /LPT2 /READ CODE.BIN
Example 4:
Read the DATA memory and write to file DAT2.BIN
The Programmer is connected to LPT2.
ISP_HB.EXE /LPT2 /READ /DATA DAT2.BIN
|
What
operating system?
You
can use this software works in DOS through Windows 98/ME.
Windows NT, 2000 & XP users need to also download
a software to enable direct I/O Port access for the ISP tool.
Here is the commandline for Port Talk:
ALLOWIO.EXE 0x378 ISP_HB.EXE /LPT1 /ERASE
file.bin
I
suggest the use of PonyProg with WinNT/2000/XP.
This
tool is freeware.
The only thing I ask for is to sign my guestbook if you
use my tool.
|
ATMEL
AVR
This tool
is available for DOS, Win98 and Linux in our download
section
|
AT89S8252
This is
a DOS command line tool.
You can find it in our download section
|