Qsort function is a generic sorting function which allows to choose your own sorting criterion. Not often but sometimes you may need to have some sort of array of data. Dont go to much in to it what data type you will be storing in your embedded application but lets say it is a simple notebook based on AVR. Lets analyse simple program how data can be sorted by using function pointer.
Lets start with sample data. In my example I will use simple structure of four fields:
Input signals in microcontrollers may be digital or analog. Digital signal may have two values “0” and “1” while analog any value in given interval. while AVR microcontroller may operate with only digital signals, analog signals have to be converted to digital. Mega series of AVR have built in ADC inside chip what makes this task much easier. Lets take Atmega8 as example. If Atmega8 DIP, then it has 6 ADC inputs, if package is TQFP-32 or MLF, then there are two additional ADC inputs. All ADC channels have 10 bit resolution. Bellow you see simplified Atmega8 ADC unit. Input signals come from pins PC0-PC5. Then enters multiplexer and according to ADMUX register signals is sent from one pin to ADC converter.
All AVR microcontrollers contain same AVR core which is RISC architecture. So program or its parts written for one AVR will work in another AVR microcontroller. So it is enough to learn one AVR MCU and you can work with all other.
To make circuit work normally you need to follow several conditions: apply power supply, clock device, organise reset after power-up and connect peripherals to I/O. All this information you can find in data-sheets. By the way, Atmel datasheets are very well organised and unified. They are easy to read and there is no stress when changing AVR microcontrollers because you intuitively know where to find required information without pain. If you take like NXP ARM MCU documentation you will see how hard can it be to access required information, because datasheets are poorly organized while microcontrollers are really good. But leave this for another topic.