Some good news for those who are tired of writing same program parts every time. Most time consumption is during initial code writing. The guy named tcg in avrfreaks have decided to write code generating tool which could robust most common tasks.
Current version of program is v0.009 (early beta stage of program) but it already support baud calculator, timer calculator, multitasking generator, interrupts, ports and more. But there are several thing to be done like TWI, USI. As Author states there is lots of testing to be done. Project is open for new ideas and suggestions.
AVR-GCC compiler is changing during the time. There are so many things changed from recent versions of WinAVR to now. C language itself doesn't change much, but functions that deal with hardware all the time. Earlier even set up interrupt service routines would take some brain, now it is simplified to just one simple function ISR(). All necessary job is handled in macro level.
Another very important issue is operations with I/O bits. Functions with bits have changed since old versions of WinAVR. Compiler just throws errors that functions cannot be found. One solution is to write your own macros to support them or change the code with new syntax. Or use special Patch program which returns old functions to new WinAVR. You can download this patch from myrobot.ru. This patch returns functions that are not supported since WinAVR20050214. This is handy when you are trying to compile older source versions and do not want to change the code and do not want to download older WinAVR tools.
Standard alphanumeric LCD display controlled by 74HC164 controlled can accept 8 bit data bytes or 4 bit nibbles. Using 4 bit interface may give few benefits like you can save 4 microcontroller pins and use them for different purposes, or use small pin count Microcontrollers to control LCD like AVR ATtiny series.
When using 4 bit mode, only four data-lines of LCD (D4...D7) are used. So first is high nibble sent and then lower nibble has to be sent in order to form single byte. This way there are two cycles used to form one data or command byte. Earlier I have been using LCD library from Procyon AVRLIB, but I wasn’t satisfied with it as it generated a lots of HEX code because of many functionality included.
Lets write simple example on using AVR comparator module. Program is written in C and compiled with AVR-GCC compiler(WinAVR). Program example illustrates the case when Positive Comparator input is connected to Internal voltage regulator 1.23V by setting ACGB bitin ACSR register. Also as negative comparator input is taken ADC3 input via Multiplexer. As indicator LED is connected to PORTD0 pin. If input voltage is lower than 0.23V then Diode is OFF and if voltage exceed 1.23V diode lights ON. Diode state is changed with ANA_COMP_vect interrupt service routine on ACO bit toggle in ACSR register.