Program Flow In Embedded C

Program Flow and control is a control method of your program. For example Loop constructions control repeated execution of repeated program segments where control is taken by control parameter. In this article we will go through if/else switch/case statements and loop sentences like while, do while, for. While statement As I mentioned three looping sentences available in C language one of them is While sentence. Lets take an example: #include <stdio.h> int main(void) { int guess, i; i=1; guess=5; while (guess!=i) { i=guess; guess=(i+(10000/i))/2; } printf(“Square root of 10000 is %d\n”, guess); return 0; } While(guess!=i) invokes looping operation. This causes statement to be executed repeatedly at the beginning the condition guess!=i is checked. As long the argument is TRUE the while sentence will be continued continuously. When guess becomes equal to i while statement will be skipped. I am not going to deep in to it as there are…

Continue reading

Control AVR 8 bit Timer-Counter0 using AVR-GCC

Timers are very important part of embedded systems. They make your life much easier if used properly. Timers runs independently to main program flow, so they can do job independently without disturbing precious calculations done by CPU. You just set up the timer and let it run while your main program perform other tasks. Timers are really easy to set up. In this post an example is made for Atmega8 timers. Other AVR microcontroller models and even different brand ships have similar timers. Atmega8 has two 8 bit timers/counters and one 16-bit timer counter with many abilities. Standard 8-bit Timer/Counter0 features are: Single channel counter; Frequency generator; External Event counter; 10 – bit clock prescaler. TCNT0 is 8 bit timer counter register which keeps the current count number. Timer counter can be clocked by an external clock through pin T0 or from internal via pre-scaller. Timer counter is incrementing (MAX…

Continue reading

Why C instead ASM

ASM is a specific language also referred as low level programming language. It is a mnemonics to a machine codes. It usually takes long time to develop embedded programs in ASM language. Today even modern 8 bit microcontrollers are powerful and complex as they were long time ago. The program memory of tiny chips are reaching megabytes, they pack lots of peripherals and interfaces. Hardware code is becoming more complex, functionality grows up. This is one of the main reasons of using higher level programming languages like C. By using C language you do not have to go into details how processor works at hardware level. You don’t have to think about hardware logic how bytes are shifted between registers. It is better to leave t Another advantage of C language against ASM is portability. If you work with embedded system architecture and decide to move to other, and your…

Continue reading

Tips to improve your electronic designs

Electronic designs cover a wide array of technical options. In this post, we will cover some of the basics that will help you improve your electronic designs and make sure that you complete it successfully. 1. Block diagram The first part of your design schematic is a block diagram. Block diagram should be an extract from the document showing the hardware design. This particular section is similar to outlining an essay. This is because it gives the design an overview of the architecture and the reader gets a reference. If you want your block diagram to look great, make sure that you include page numbers in the schematic sections. 2. Naming the nets This can be a time-consuming process, but if you want to state the purpose of every net, you need to name them. Apart from this, naming the nets will help you in debugging the program and allow…

Continue reading

4 Reasons to Study STEM

The term STEM refers to an education that is focused on four specific areas. These areas of study are science, technology, engineering and mathematics. STEM education is supposed to help students learn these topics in a unique way, focusing on interdisciplinary studies, as well as applying the knowledge that has been learned. The interest in STEM has changed over time, but here are four reasons to study STEM. Job Opportunities When choosing a career, it is important to consider if there are jobs available in that particular field. In the case of the STEM subjects, this is not a worry. There are a wide variety of jobs available in these four fields. If a person is not interested in working in the STEM fields specifically, the skills that are learned in STEM classes can be transferred to most other jobs. This includes skills like innovation and creativity, as well as…

Continue reading

How to Create Your Own Music Room

A music room in the home is a great addition that can be enjoyed by everyone, old and young. No matter whether you are a budding musician, an established musician, or just want to have one in your household, creating that space for playing your favorite instruments is a great project to start. When designing your music room, a lot will ride on the types of instruments you will have in there. Perhaps you are thinking of filling your entire home with soothing classical piano tunes. Whatever the music style you are going for, there is the element of design to consider before you make a space wholly dedicated for sound. When put together, your music room should work in harmony with the rest of your home in terms of ambience as well as reduced noise levels, but still be a room where you can gather your family and friends,…

Continue reading

Are we going full wireless?

The short answer to this question is “yes”. However, how soon is yet to be determined. Probably, it’s not gonna take too long if the current technology development speed is anything to go by. How many wireless-enabled gadgets do you have in your possession already? At the very least, a Wi-Fi router seems to be present in many if not most homes in the USA. With Wi-Fi Internet at home, we can get rid of all the cords that come with printers and scanners. Smart TVs usually connect to the world network via Wi-Fi as well (though you can choose to use a cable if your wireless speed is somewhat slow-ish). The Internet of Things (IoT) is spreading at an unbelievable rate. Wi-Fi helps elderly and physically-challenged to actively take part in the modern society’s life, wireless automation within industries simplify and accelerate the production processes, we install more and…

Continue reading