The AVR micros from Atmel are becoming quite popular, due in part to their ease of programming and a good Basic compiler along with gcc for C development. You can program many AVRs with our XCP1 JTAG kit (which is actually meant to program Xilinx CPLDs).

If you use gcc, you will want to check out our PAKs and GCC page (which uses an ATMega 16 as an example). If you prefer assembly language, keep reading!

The PAKs will work fine with the AVR. I've written an assembly language library that lets you use a PAK-I or PAK-II floating point math coprocessor with an AVR. The library is wrapped in BASCOM subroutines so that you can use it from Basic or pull the routines out for use with assembly language. Of course, if you are using Basic you might just as well use SHIFTIN and SHIFTOUT. You'll have to tune the delays to match your processor speed, but otherwise you shouldn't have to do much to get it to work. It would be easy to adapt the library to work with PAK-III, IV, VII, VIII, or IX parts.

Here is a simple program that uses the library:

' Example for PAK1.INC. See PAKDEF.INC for instructions
' and more info

$crystal = 1000000

Config Pinb.0 = Output                                        ' indicator led

Dim X0 As Byte                                                ' general-purpose
Dim Iresult As Integer                                        ' General integer


' Get PAK library definitions
$include c:\pakdef.inc
Wait 5                                                        ' reset delay
X0 = &HFF
Call Pakreset                                                 ' always reset first
Top:
Pakdir &HFF                                                   ' all outputs
Pakwio X0                                                     ' write to outputs
If X0 = &HFF Then X0 = 0 Else X0 = &HFF                       ' toggle for next time
Reset Portb.0                                                 ' Turn on LED
' Compute 1/2 * 10 using integers
' Could also use FConvert to preconvert these to floats and
' and load them directly
Pakloadint 2
Pakswap
Pakloadint 1
Pakdiv
Pakswap
Pakloadint 10
Pakmult
Iresult = Pakreadint()
' Answer better be 5!
If Iresult = 5 Then Set Portb.0
Wait 10                                                       ' do it all again
Goto Top


' Get PAK library code
$include c:\pak1.inc

End

You can download the library in a zip file, avr.zip. If you'd like to read the PAK-I manual online, you can find it in the document library.

Other AVR Resources

AVR gcc PAK Library

Programming AVR with the XCP1


Site contents © 1997-2018 by AWC, Houston TX    (281) 334-4341