Skip to main content

Featured post

Digital Clock On LCD (16x2) PIC16F1937 Used In FlowCode Programming and Simulation

In this sample project we are using FlowCode Simulation Software for Programming and Testing with PIC16F1937.It shows how to use and simulate and program LCD for use in different projects.In this Project we have created digital clock(Using two digit each for seconds minute and hours in 24 Hour format on LCD) on 16x2 Liquid Crystal Display.Varying the delay and write-erase sequence can be manipulated to get desired result.

Here is the Flow code program:
LCD(16x2) Display Related Programs
ADC-Voltage as Float(LCD with PIC16F1937)
ADC-Voltage as String (LCD with PIC16F1937)
ADC Sampling and outputting to a LCD(LCD with PIC16F1937)
Printing Number on 16x2 LCD Display with PIC16F88
Printing and Updating Number on 16x2 LCD Display
Printing a Two line(String) message (LCD 16x2)
Printing a formatted number on ( LCD 16x2 ) Using PIC16F88

LCD (Liquid Crystal Display 16X2):-
Its screen is an electronic display module and find a wide range of applications. A 16x2 LCD display is very basic module and is very…

Programming Using Embedded C

Embedded C use most of the syntax and semantics of standard C, e.g., main() function, variable definition, data type declaration, conditional statements (if, switch. case), loops (while, for), functions, arrays and strings, structures and union, bit operations, macros, etc. In addition, there are some specifics to embedded C which are mentioned below: 

1. Low Level Codes

Embedded programming requires access to underlying hardware, i.e., timers, memory, ports, etc. In addition, it is often needed to handle interrupts, manage job queues, etc. As C offers pointers and bit manipulation features, they are extensively used for direct hardware access

Suggested Readings

Embedded Systems and C Programming - Home Page - Index

More Links:

Embedded C know How
Difference Between C and Embedded C
Embedded Systems(Micro controllers) Programming and Simulation Using Flow Code
Embedded Electronics-Real-time software-Introduction
Karnaugh_Maps-Digital Electronics Tutorials
Micro-controllers-Basic Introduction Tutorials

2. In-line Assembly Code
For a particular embedded device, there may be instructions for which no equivalent C code is available. In such cases, inline assembly code, i.e., assembly code embedded within C programs is used; the syntax depends upon the compiler. An example for ‘gcc’ is shown here.
int a=10, b;
asm (“movl %1, %%eax;
movl %%eax, %0;”
:”=r”(b) /* output */
:”r”(a) /* input */
:”%eax” /* clobbered register */
);

Assembly code is written in C program itself. Above code assigns ‘a’ to ‘b’. Writing inline assembly code is much easier than writing full fledged assembly code.

3. Features like Heap, recursion
Embedded devices have no or limited heap area (where dynamic memory allocation takes place). Hence, embedded programs do not use standard C functions like malloc. Structures like linked lists/trees are implemented using static allocation only.
Similarly, recursion is not supported by most embedded devices because of its inefficiency in terms of space and time.
Such other costly features of standard C which consume space and execution time are either not available or not recommended


4. I/O Registers
Micro controllers typically have I/Os, ADCs, serial interfaces and other peripherals in-built into the chips. These are accessed as IO Registers, i.e., to perform any operation on these peripherals, bits in these registers are read/written.
Special function registers (SFRs) are accessed as shown below:
SFR portb = 0x8B;
It is used to declare portB at location 0x8B.
Some embedded processors have separate IO space for such registers. Since there are no such concepts in C, compilers provide special mechanisms to access them
unsigned char portB @portB 0x8B;
In this example, ‘@portB <address>’ declares portB at location 0x8B by the variable portB.
Such extensions are not a part of standard C, syntax and semantics differ in various embedded C compilers.

5. Memory Pointers
Some CPU architectures allow us to access IO registers as memory addresses. This allows treating them just like any other memory pointers.

6. Bit Access
Embedded controllers frequently need bit operations as individual bits of IO registers corresponds to the output pin of an I/O port. Standard C has quite powerful tools to do bitwise operations. However, care must be taken while using them in structures because C standard doesn’t define the bitfield allocation order and C compilers may allocate bitfields either from left to right or from right to left.

7. Use of Variable data type
In C, datatypes can be simply declared, and compiler takes care of the storage allocation as well as that of code generation. But, datatypes usage should be carefully done to generate optimised code. For most 8-bit C compilers, ‘char’ is 8-bits, ‘short’ and ‘int’ are 16-bits, long is ’32-bits’.
Some embedded processors favour use of unsigned type. Use of ‘long’ and floating variable should be avoided unless it is very necessary. Using long data types increase code size and execution time. Use of floating point variables is not advised due to intrinsic imprecise nature of floating point operations, alongside speed and code penalty.

8. Use of Const and Volatile
Volatile is quite useful for embedded programming. It means that the value can change without the program touching it. Consequently, the compiler cannot make any assumptions about its value. The optimizer must reload the variable every time it is used instead of holding a copy in a register.
Const is useful where something is not going to change, for e.g., function declarations, etc.

Comments

KeyWords

Show more

Popular posts from this blog

Digital Clock On LCD (16x2) PIC16F1937 Used In FlowCode Programming and Simulation

In this sample project we are using FlowCode Simulation Software for Programming and Testing with PIC16F1937.It shows how to use and simulate and program LCD for use in different projects.In this Project we have created digital clock(Using two digit each for seconds minute and hours in 24 Hour format on LCD) on 16x2 Liquid Crystal Display.Varying the delay and write-erase sequence can be manipulated to get desired result.

Here is the Flow code program:
LCD(16x2) Display Related Programs
ADC-Voltage as Float(LCD with PIC16F1937)
ADC-Voltage as String (LCD with PIC16F1937)
ADC Sampling and outputting to a LCD(LCD with PIC16F1937)
Printing Number on 16x2 LCD Display with PIC16F88
Printing and Updating Number on 16x2 LCD Display
Printing a Two line(String) message (LCD 16x2)
Printing a formatted number on ( LCD 16x2 ) Using PIC16F88

LCD (Liquid Crystal Display 16X2):-
Its screen is an electronic display module and find a wide range of applications. A 16x2 LCD display is very basic module and is very…

Motor Types- Special Types of Motor

Motor Types- Special Types of Motor
1. Iron less or core-less rotor motorNothing in the principle of any of the motors described above requires that the iron (steel) portions of the rotor actually rotate. If the soft magnetic material of the rotor is made in the form of a cylinder, then (except for the effect of hysteresis) torque is exerted only on the windings of the electromagnets. Taking advantage of this fact is the core less or iron less DC motor, a specialized form of a PM DC motor. Optimized for rapid acceleration, these motors have a rotor that is constructed without any iron core. The rotor can take the form of a winding-filled cylinder, or a self-supporting structure comprising only the magnet wire and the bonding material. The rotor can fit inside the stator magnets; a magnetically soft stationary cylinder inside the rotor provides a return path for the stator magnetic flux.

INDEX-Tutorials for Flow Code Programming and Simulation

Categorized Topics
We are using Flow Code Simulation Software from MATRIX for Programming and Testing,You will find topics from Flow Code Programming and Simulation.You can request a topic here.If some links are not working please let me know.
Flowcode is one of the world's most advanced graphical programming languages for micro-controllers. The great advantage of Flowcode is that it allows those with little to no programming experience to create complex electronic systems in minutes. Flowcode is available in multiple languages and currently supports the PICmicro, dsPIC, PIC24, AVR/Arduino and ARM series of micro controllers.You can Download the Demo Software HERE.







INDEX
Seven Segment LED Display 
Using Seven Segment with PIC16F88Counting using loops(Seven Segment with PIC16F88)Counting switch presses(Seven Segment with PIC16F88)
Timers and Counters
Timed Counter And Use of Timer Interrupt(PIC16F88)
ADC Programming
ADC Simulation In Flow CodeServo with ADC control input ,Flow Code Simulati…

Pong game Example Using PIC16F877 - FlowCode - Graphical LCD Simulation

Here example of PONG game is used for demonstration on Graphical LCD in Flow Code Simulation Software.You will be able to play the game while simulating the program.

In this program Red and blue colors are use for two different sides on the LCD.Here micro-controller used is PIC16F877.

Here is the Flow code program:
You may like:
Graphical LCD-3D Text Example
Graphical LCD-2 Channel Scope Example

Here is the complete list of projects:
Tutorials for Flow Code Programming and Simulation
Macro Used in Programming are

Stepper Motors Examples with PIC16F88 -Flowcode Simulation

We are using FlowCode Simulation Software for Programming and Testing with PIC16F88 for Simulation of this project .It shows how to use and simulate and program Stepper Motors for use in different projects.

For concept of Different types of Motors and their properties please see:
Motor Types-Introduction
Motor Types- DC Motor
Motor Types- AC Motor
Motor Types- Special Types of Motor
Servo Motors
Here is the Flow code program:
Three Stepper are used to depict different configurations in which they can be used .Here functionality of auto off capability is used.It can be programmed to moved back to its original position if required.

More related Post :
Stepper motor Control using switches(Flow Code Simulation)
Stepper with switch control- Auto Off with PIC16F88

Here is the complete list of projects:
Tutorials for Flow Code Programming and Simulation

ADC-Voltage as Float Value Displaying On LCD with PIC16F1937 Microcontroller - Flow Code Simulation

Here is the example of using ADC and manipulating the variables for desired results.In this example we are using LCD to display the results of ADC calculation as float values on the LCD as seen in the examples code and videos.

Flow code program:
LCD(16x2) Display Related Programs
ADC-Voltage as String (LCD with PIC16F1937)ADC Sampling and outputting to a LCD(LCD with PIC16F1937)Printing Number on 16x2 LCD Display with PIC16F88Printing and Updating Number on 16x2 LCD DisplayPrinting a Two line(String) message (LCD 16x2) PIC16F88ADC SimulationServo with ADC control inputMotor TypesDC MotorHere is the complete list of projects:
Tutorials for Flow Code Programming and Simulation

Micro-controller used is PIC16F88 with 16x2 LCD for printing numbers and then updating them.

In video you will be able to see step-wise execution of program and their effect on LCD in panel which is by default in the software .

Here is the Flow code Simulation and how to do Video Tutorial:

You can Download Flow Code Pr…

Fibonacci Numbers Series Progression Using While Loop - C Programming Examples

As we have started C Programming coding with Example Series, We have published last posts
"Write A Program For SUM of Infinite HP"
"Write A Program To Find SUM of AP" and
"Write A Program To Find SUM of GP Sequence".
We have chosen to start with Arithmetic Series and in this post you will find some basic idea and some useful concepts about Fibonacci Numbers .You can download C Codes below.Please let us know your feedback.

Fibonacci Numbers Progression - Series - Sequence to Nth Term Step-wise Video Tutorial(See C- Codes Below ):

Fibonacci Sequence:-The Fibonacci Sequence is the series of numbers:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...The next number is found by adding up the two numbers before it.

The 2 is found by adding the two numbers before it (1+1).Similarly, the 3 is found by adding the two numbers before it (1+2),And the 5 is (2+3),and so on!

Timed Counter And Use of Timer Interrupt Using PIC16F88 Microcontroller - Flow Code Simulation

Flow Code-Timed Counter And Use of Timer Interrupt(PIC16F88)

In this example of counting seconds using Timed Counter and Timer Interrupt.In this example we are using 7 Segment Display to display the results of calculation as seen in the examples code and videos.

Here is the MACRO for Interrupt Program Code:


Here is the Flow code MAIN program:
Complete list of projects:
Tutorials for Flow Code Programming and Simulation

LCD Interfacing With Keypad PIC16F877A FlowCode Microcontroller Programming And Simulation

In this sample project we are using Programming Software FlowCode for Programming LCD ( Liquid Crystal Display ) With Keypad and Testing And Interfacing with PIC16F877A.It shows how to use and simulate and program Keypad with LCD for use in different projects.In this Project we are testing Keypad and outputting binary values to LCD ( Liquid Crystal Display ).Varying the delay and write-erase sequence can be manipulated to get desired result.

Above is the Flow code program Snapshot:

Recent Related Programs
Keypad and LED Interfacing With PIC16F88

LCD(16x2) Display Related Programs

Voltage as Float(LCD with PIC16F1937)
Voltage as String (LCD with PIC16F1937)
ADC Sampling and outputting to a LCD
Number on 16x2 LCD Display with PIC16F88
Printing and Updating Number on 16x2 LCD Display
Two line(String) message (LCD 16x2)
Printing a formatted number on ( LCD 16x2 )

OutPut On LCD Dispaly And LED Strip is as Given.This data is Further Used for Interfacing in other big and complicated Projects
Keypad LED …

Servo with ADC control input ,Flow Code Simulation

Servo with ADC control input ,Flow Code Simulation
In this simulation we are working with two servo channels as o/p and two ADC channels for input and Output.
You may also like :
Servo with ADC control input
Stepper motor Control using switches
ADC Simulation In Flow Code 
Pulse Width Modulation Simulation (PIC16F877)

Here is the complete list of projects:
Tutorials for Flow Code Programming and Simulation