***************************************************************************************
HTBLA Eisenstadt             ReadMe-MegaPAC-english.txt                     2003-05-18
***************************************************************************************
                             PLEASE READ CAREFULLY!

This folder contains only software and data which are free available in the Web.
All parts not written by myself are marked so and contain the references and credits. 
  

Content of this folder and features of the board:
-------------------------------------------------- 
Contains the software for programming ATMELS AVR ATMega8 in "C" and documents, 
describing the hardware of the low-cost - evaluation board MegaPAC of the technical 
school HTBLA Eisenstadt in Austria (department for mechatronics).
The ATMega8 is a cheap, but fast (16 MHz) and modern 8 bit- Microcontroller with 
USART, 10 Bit - AD-Converters, etc....  
Our board has serial In-cicuit-programming, a low cost 1x16 char LC-display (with 
library souce code included), 4 output drivers (max. 0,5 A), voltage stabilizer, etc.
The board is a single - layer eurocard (100x160 mm) with much spare space for own
circuits. 
Total costs are below 50 Euro, and include a flat ribbon cable for programming
and for the serial RS-232 - communication. 
Therefore this equipment is well suited for students and beginners. 
After working with the 8051 and the PIC16F84 for some years, this is at last the 
cheapest, but also the most powerful evaluation environment.
All the software and the programming is working under WIN 98, WIN 2K and WIN XP.
 
----------------------------------------------------------------------------------------

\AVR-Studio-ATMEL	Integrated development environment of ATMEL (freeware).
			For debugging and simulating the programs.
			DOWNLOAD >>> http://www.atmel.com/
			Thanks to ATMEL !

\CVAVR			Code-Vision - C-Compiler and IDE.
			Version: Evaluation (free but only memory model TINY,
			is sufficient for out test programs).
			DOWNLOAD >>> http://www.hpinfotech.ro/html/download.htm
			Thanks to Pavel Haiduc !

\documents		Pdf-Files:  Datasheets and applications for AVRs and
			peripherals. Data sheet of ATmega8. 
			DOWNLOAD >>> http://www.atmel.com/   Thanks to ATMEL !

\MegaPAC		All documents for the evaluation-board MegaPAC
			DOWNLOAD >>> http://www.flamisch.at/download

\projects		Examples and test - programs, C-source code and special
			INCLUDE- and LIBRARY - files (especially for the LCD).
			DOWNLOAD >>> http://www.flamisch.at/download
			
\PonyProgram		Free programming software, suited for our serial In-circuit
			programming of the MegaPAC.
			DOWNLOAD >>> http://www.lancos.com/prog.html
			Thanks to Claudio Lanconelli !

\Progr in C		Webcourse about programming of AVR-Microcontrollers in "C".
			In German!
			DOWNLOAD >>> http://www.mikrocontroller.net/articles/c/
			Thanks to Christian Schifferle !
			Caution! Examples are not directly applicable to our
			hardware!

\utilities		Some useful tables for working with Microcontrollers
			in "C" (C-syntax, ASCII-Code, etc..)

----------------------------
Installation of the programs:
----------------------------

First, if not installing from our CD, load down all the zipped software mentioned
above and unzip to temporary folders. 


1. Install AVR-Studio-ATMEL by Setup (needed for debugging/simulating)
   Accept all "defaults".
   
2. Install CVAR (Code Vision Compiler) by Setup.
   Accept all "defaults".
   (maybe without "RUN" at the end ...)

3. Install programming software PonyProg by Setup.
   Click to o.k. if there are two message boxes at first start.
   
4. Make folder ..\cvavr\projects and copy all the programming examples of 
   ..\Atmel-AVR\projects (with subfolders) to there. Remove write protection, if set.
   
5. Copy all the special library and include - files for the MegaPAC from
   ..\projects\save-lib und  \projects\save-inc into the standard folders
   ..\cvavr\lib  bzw.  ..\cvavr\inc , so that the compiler will find them.

--------------------------------------------
First usage and adjusting of the programs:
--------------------------------------------

1. 	Start CodeVision AVR.
	File-> NewProject -> (without Code Wizard) make new project in "\projects" 
	for example "MPACTest.prj".
	Add files -> add Soucefile "MegaPAC1.c".
	In "C-compiler": choose Chip "ATMega8", Clock at 16,00 MHz. 
	Leave all the others. -> O.K.
	Start Compiler with project -> Make, then check errors, if there are ... 
	(finds the compiler all needed include und library - files, and so on ...)
	If there are no errors, the compiler is working correct.
	Caution: Do NOT use the programmer of the CVAAVR! It will not work with the
	MegaPAC! We will use the freeware PonyProg (see below).

2.	"Run Debugger" (icon red bug) in CVAVR will start the ATMEL AVR-Studio.
	Here you must choose "AVR Studio4" and the correct path (use "browse"...)
	normally: ..\Programs\Atmel\AVR Tools\AVR Studio 4\AVRStudio.exe).
	Here with "Create new project"-> "OPEN" choose file "MegaPac1.cof" (was 
	created by compiler with debugging information).
	Debug Platform: "AVR Simulator", Device: "ATMega8", -> "Finish".
	Debug-window with sourcecode has to come now. If o.k., finish Debugger 
	AVR-Studio for now. 

3.	Open programmer software PonyProgram, confirm the two starting messages.
	Call setup -> calibration, for the timing of the com-port.
	Call setup -> interface Setup-> choose COM1 oder COM2 leave the rest to
	serial, SIProg API). Testing with "probe" works only. if the hardware is 
	already attached!
	Load hex-file for programming with "open device file".  Browse in 
	 ..\cvavr\projects (file extension to *.hex!),  open "MegaPAC1.hex" .
	Switch to "AVR Micro" and "ATMega8" in the windows right above.

CAUTION: >>>>>>>
 	
	Only at the first programming of the ATMega8 you must program the used
	oscillator (extern crystal 16 MHz) by programming the cojmmand -> 
	"configuration and securits bits".
 	If you set the wrong bits here, maybe you can program the chip never again
	in a serial programmer!!! In that case you have to change some config. bits  
	in a "real" parallel programmer, e.g. the GALEP-4.
	The original default-sets for the Mega8 you may see on the screenshot
	"PonyProg-M8-ConfBits-original.jpg" in this folder.
	Note: 	Config. Bit not programmed = not checked = logical 1 !
		Config. Bit programmed = checked = logical 0 !

	Therefore:
	"Read" the configuration bits (sometimes called "fuse-bits").
	If not done, disable CKSEL1, CKSEL2 und CKSEL3 (--> uncheck)!
	This will enable the external 16 MHz-Crystal.
	Do not alter the other bits, if you do not exactly know, what you're doing!!!!
	"Write" this configuration back to the chip. 

	Now you can "burn" your program to the chip.
	Start the programming with "Command" -> "Write all" (or ICON).  ->O.K.
	The green power-LED of the MegaPAC will flash and then go out, while
	programming.
	After finish (->o.k) reset the MegaPAC, if your program does not start proper.
	While programming, the LC-display does not alter its content, because it has
	its own RAM.  
	
4.	Check the hardware by testing the program MegaPAC1 (press Key T1, and so on ...)
	The AD-value of AD0 (Pot R3) will be sent as decimal number (0 - 1023 = 10 bits)
	to the LCD and out to the serial COM-port (plug serial programming cable to XC!).
	In CVAVR open "TERMINAL" and look for the received numbers.
	After testing, "disconnect" the serial interface in terminal and plug cable
	to XP again for further programming. 


	HAVE FUN WITH THE MEGAPAC AND "C"!    S. Flamisch    
	
	Please, mail errors to >>> siegfried@flamisch.at
