Embedded System - Unit II (Prepared by N.Shanmugasundaram)
-
Upload
nshanmugasundaram -
Category
Documents
-
view
490 -
download
0
description
Transcript of Embedded System - Unit II (Prepared by N.Shanmugasundaram)
Embedded SystemUnit II – Mixing C & Assembly
Prepared by
Prof. N.ShanmugasundaramHOD / ECE, VVCET.
Programming Embedded system can be accomplished
in three different ways, by using programming languages like …
1. High level languages (like C, C++, Java…)
2. Assembly language (using Mnemonics, Eg. ADD, MOV, etc.)
3. Machine level language (using OPCODES, Eg. 80H for ADD B)
Embedded System – Unit II
Advantages of different level programming …
High level language (like C ) i) easy understandable program ii) portability into diff processor
Assembly level language i) compact code (compared to C) ii) access to the special features of
the processor hardware.
Machine level language i) Highly compact code ii) Fast execution
Embedded System – Unit II
Embedded System – Unit II
Data Type Conversion
Embedded System – Unit II
Embedded System – Unit II
Embedded System – Unit II
Manipulating Bits in Memory
Embedded System – Unit II
Embedded System – Unit II
Embedded System – Unit II
Embedded System – Unit II
Embedded System – Unit II
Embedded System – Unit II
Testing of Bits
Embedded System – Unit II
Setting, Clearing and Inverting of Bits
Embedded System – Unit II
Embedded System – Unit II
Embedded System – Unit II
Extracting of Bits
Embedded System – Unit II
Inserting of Bits
Embedded System – Unit II
Manipulating of Bits in I/O Ports
Embedded System – Unit II
Embedded System – Unit II
Write-only I/O Ports
Embedded System – Unit II
Embedded System – Unit II
Ports differentiated by Sequential Access
Embedded System – Unit II
Ports differentiated by Bits in written data
Embedded System – Unit II
Accessing Memory mapped I/O Devices
Most modern microprocessors are capable of addressing GBs of Memory, but embedded systems need only a few KBs of memory.
By assigning few unused memory address to I/O devices, these devices can be accessed as if a memory is being accessed.
A typical example of memory mapped I/O device is Display buffer (each character position in screen is assigned with one / more unique address).
In IBM-PC, color display buffer is mapped with memory address B8000H.
Each charater is assigned with 2 bytes, first byte for ASCII code of that character and second byte for the foreground and back ground color information.
The address of the first byte of a specific row & column is calculated as
B8000H + 2 (80 x Row + Column)
Embedded System – Unit II
Accessing data through a pointer
In C,
We create a variable (ie., allocate memory for it) by declaring it;And then manipulate its content by referring to its identifier.
Example: int a;a = 5;
Alternate method to access a memory location is by using a pointer(Pointer is a variable that holds an address of memory location)
Example: int a, b;int *c ;
a = 5 ;c = &a;b = *c;
Typical programming to access display buffer through pointer variable is ...
Declarationchar *p ; /* “p” is a pointer to a char */
Initializationp = (char *) (0xB8000 + 2 * (80 * row + col)) ; /* p is intialized */
Declaration & Initializationchar *p = (char *) (0xB8000 + 2 * (80 * row + col)) ; /* declaration & initialization */
Assigning a value to pointer variable*p = ‘ A ‘ ; /* char ‘A’ is assigned to addr of p */
Embedded System – Unit II
Embedded System – Unit II
To display a text on screen; we can use a Pointer.
Embedded System – Unit II
Embedded System – Unit II
Embedded System – Unit II
Embedded System – Unit II
Structures
Embedded System – Unit II
Embedded System – Unit II
Packed Structures
Embedded System – Unit II
Packed Structures
Embedded System – Unit II
Bit Fields
Embedded System – Unit II
Embedded System – Unit II
Embedded System – Unit II
Embedded System – Unit II
Embedded System – Unit II
Embedded System – Unit II
Embedded System – Unit II
Embedded System – Unit II
Embedded System – Unit II
Embedded System – Unit II
Embedded System – Unit II
Embedded System – Unit II
Embedded System – Unit II
Embedded System – Unit II
Embedded System – Unit II
Embedded System – Unit II
Embedded System – Unit II
Embedded System – Unit II
Embedded System – Unit II
Embedded System – Unit II