What is surface mounting?

Simply talking surface mounting is a soldering technology where the component is soldered directly to a series of solder pads called a footprint. It is different soldering technology from through-hole, where component leads are inserted into holes of the board. The footprint is a series of pads that conform to the lead layout of packages of surface mount devices (SMD). Surface mounting has several advantages over through-hole technology. First of all the board become much smaller. So smaller boards and more dense placement of elements reduce costs. Because of higher placement density, traces between components becomes shorter. It lowers parasitic inductance and capacitance.

Continue reading

Control memory sections using AVR GCC

Sinewave DDS signal

If you are programming AVR microcontrollers in C, usually don’t think about how the compiled program is stored in microcontrollers’ flash memory. The compiler organizes data in the way it looks optimal. But sometimes, you are working with programs where you need to code chunks located in specific program memory locations. For instance, I faced this problem while developing an AVR controlled signal generator. I wanted to make an efficient and compiler independent main loop where the signal has to be read from flash memory and transferred to port. I managed to use the inline ASM function, which does the job: The linker produces ASM code like this:

Continue reading

How to measure signal period using microcontrollers

Measuring the signal period is a common problem in embedded systems. This can be measuring the time between two events or measuring signal frequency f=1/T and so on. Measuring the time interval or period is based on comparing event time t with discrete-time usually produced by a timer. This usually is done by filling the event time t with discrete-time intervals t. According to this, the discrete-time signal period has to be much shorter than event time: t<< t. Then counting these short time intervals, we can determine the event time.

Continue reading

Why to move from ASM to C

ASM language is a low-level programming language. It takes tons of time to develop embedded programs. Now even 8-bit microcontrollers aren’t as small as they were earlier. The program memories are climbing to a megabyte(s). Program structure becoming more complicated because of the bigger functionality demand. This is why it is better to use higher-level programming languages like C. By using C language, you are not overwhelmed by details. You don’t always have to think about hardware logic to be able to program its restricted tasks. It is better to give this work to the C compiler, which helps you avoid bugs at the silicon level.

Continue reading

Shelling The Intel 8-bit Hex File Format

Intel 8-bit Hex File Format is the most common hex file format used globally, as far as I know. There is also Motorola Hex file format and maybe others. Creating applications with AVR-GCC, we usually select ihex output file format what means Intel hex file format. Let’s go through it and see what’s inside. It is simple as 6 and 6 (six and six) because each Hex file line consists of six parts. And there can be 6 record types in the hex file. Lets go through all six parts of each line:

Continue reading

Easy start with AVR EEPROM using WinAVR

AVR microcontrollers are loaded with some amount of EEPROM (Electronically Erasable Read-Only Memory ) memory. This is a handy feature allowing developers to store program parameters like service information, constants, menu strings, etc. Atmel states that AVR EEPROM memory can be rewritten over 1000000 times. Reading is unlimited. In this article, I am going to show how to store data to EEPROM by defining variables. For this, we need to include eeprom.h header from avr directory (#include “avr/eeprom.h” ). Then we can write a simple variable declaration using the simple attribute EEMEM: EEMEM keyword indicates to the compiler that variables are stored in EEPROM, and it creates a separate .eep file that has to be written to chip separately. Se what I have got after compiling the above code: You can see compiler information about compiled code sizes. The bold line is indicating the size of occupied EEPROM memory. In this particular case, we see that size is 8 bytes: one-byte variable, one word (two bytes), and a five-byte array – total 8bytes. Open .eep file located in the project folder. The compiler compiled Intel Hex File of EEPROM data: :0800000054657374005555109E :00000001FF The first line shows 8-byte data stored at…

Continue reading

Signal sampling mechanism

Sampling is a process when a series of discrete samples represent the continuous-time signal. At the same time, the reconstruction is the reverse process when these samples recreating adequate continuous-time signals. Bellow, the overall process is illustrated. Sampling is a process when the continuous-time signal is recorded every T seconds by multiplying by an impulse train.

Continue reading

RS232 interface standard overview

This is a pretty old standard but still widely used in embedded systems. Using the RS232 interface standard, the data is sent bit by bit. Usually, first comes LSB. The receiver receives data by knowing the position of each data piece and delay. To ensure the quality of data transmission, we need to control the start of transmission. The acknowledgment procedure does this. Let’s take the asymmetrical type of interface RS232-C. The transmitter sends RTC (request to send) signal to the receiver. On the other hand, the receiver detects this signal, finishes the previous operation, and then sends to receiver CTS (clear to send) signal, which means that receiver is ready to accept data. Without CTS transmitter cannot start data transmission. Note: In the RS232 interface, logical “1” corresponds to voltages from -3V to -12V, and logical “0” corresponds to voltages from +3V to +12V. The logical level in the interval -3V to +3V is undefined.

Continue reading

AVR watchdog reset timer-practical approach

This is a continuing thread. Why use a watchdog variable timer. This post is about how the watchdog timer on the AVR microcontroller works and how to control it. As we mentioned earlier, the watchdog timer is a distinct timer counter, which generates a reset signal when it fills up. After the watchdog timer counts up to maximum, it generates a short pulse duration of 1 clock cycle. This pulse triggers an internal reset timer counting up to tout.

Continue reading

Why use watchdog variable timer

Most of the embedded microcontrollers contain watchdog timers. The watchdog variable timer is literally watchdog. The watchdog timer continuously inspects the program flow. Basically, if the microcontroller program hangs, then the watchdog timer resets it and brings the embedded system back to life. The idea is elementary. Let’s say, you know, that your program has to be executed during 20ms. And you know that the worst-case scenario is 30ms. Then you set the watchdog variable timer connected to the highest priority interrupt RESET. Once the Watchdog timer is triggered, the timer counts up to the time you set, and then it resets the MCU. The only way to avoid resetting is to send a command to the watchdog timer to start counting. Technically watchdog variable timer is nothing more than a retriggerable one-shot multivibrator.

Continue reading