Bascom and AVR, Larger AVR's


If your application is not too complex, the small AT90S2313 will often fit the bill nicely. However, if you need more I/O, more RAM for storing variables, more program or EEPROM memory, you need to switch to a larger controller. I have used the AT90S8535, which has 8k program memory and as it comes in a 40-pin DIP package, has plenty I/O.
My favourite controller for applications that will not fit in an AT90S2313 is the ATMega8 . Compare this controller to the AT90S2313:


With the larger AVR's, you may have to change some fuse settings. Fuse settings are used in the AVR's to determine controller start-up options. The ATMega8 default runs on an internal RC clock of app. 1 MHz. If you want to use an external crystal as with the AT90S2313, you must change some fuse settings. First determine what the default fuse settings for a new ATMega8 are. Build a basic schematic with the ATMega8 on a breadboard:



Although the ATMega8 runs initially on the internal RC clock, do attach the external components for a crystal clock.
Start TWinAvr, click on Config. The default fuse setting are:



As shown in the ATMega8 datasheet (page 24) the clock-fuses CKSEL3, 2, 1 and 0 should be set to "1111" for an external crystal:



In the TWinAvr Config window, check the CKSEL3, 2, 1 and 0 fuses and uncheck the CKOPT fuse:



The ATMega8 now runs on the external crystal with a maximum possible speed of 16MHz.

If you want other clock configurations, you will have to study the datasheet and set the fuses accordingly.

When TWinAvr gets the ATMega8 fuse settings for the first time, it runs on its internal RC clock at a speed of app. 1MHz. Although TWinAVR does communicate with the ATMega8 at a default speed of 4MHz, this seems to work ok. If you encounter problems with reading the fuse settings for the first time, you may try to lower the TWinAvr speed from 4 to 1MHz:



I have also used the ATMega32 and ATMega128. These have 32k and 128k program memory and lots more I/O and on-board peripherals. The ATMega32 is available in DIP, the ATMega128 only in SMD packages. This is how I use them:



Note that if you want to use PortF.4, 5, 6 and 7 as normal I/O pins, you must unprogram the JTAG fuse, or in other words, you must select the JTAG fuse in TWinAvr:



Here, the clock fuses are also set to the external crystal. The CKOPT fuse is programmed to be able to use the maximum 16MHz clock speed. The M103C fuse is unprogrammed as I did not need the ATMEGA103 compatibility.

Sometimes things can go horribly wrong when changing fuse settings. If your controller does not run anymore after manipulating the clock fuses, and it does not respond to TWinAvr anymore, you may try to attach a TTL oscillator output to the AVR's Xtal1 input. Check to see if TWinAvr can again communicate, change the TWinAvr clock speed if necessary. If you can again communicate, set the fuses and try again with an external crystal.

TOC