Beruflich Dokumente
Kultur Dokumente
First of all I would like to thank almighty GOD who has given this wonderful gift
of life to us. He is the one who is guiding us in right direction to follow noble path
of humanity. In my six weeks industrial training it is a wonderful experience to be
a part of HCL TECHNOLOGIES where I have opportunity to work under brilliant
minds. I owe my deep regards for the supporting and kind staff authorities who are
helping me in my lean patches during these six weeks. The knowledge I am
gaining throughout my studies have the practical implementation during this
period. I am grateful to all the staff of HCL and for their timely support and
sharing of their experience with me. I would like to express my heartiest concern
for Mr. RAJNEESH KUMAR for his able guidance and for his inspiring attitude,
praiseworthy attitude and honest support. Not to forget the pain staking efforts of
our college training and placement cell and specially my training and placement
officer Mr. 1. Last but not the least I would express my utmost regards for the
electronics and communication department of our Institute.
CONTENTS
1) Company profile
2) Embedded Systems
What is Embedded System
Applications
Difference between microprocessor & micro controller
Types of microcontroller Architectures
Difference between CISC & RISC
3) PIC microcontrollers
PIC 16F77A features
Pin diagram of PIC16F77A
Pin description of PIC16F77A
Core Architecture
Electrical Characterstics
4) Programming of PIC
Compiler Used-mikroC
Features
Projects
Functionality
5) Programming and Interfacing
Advantages of C over Assembly language programming
Project no. 1- LED interfacing and its blinking(port
programming)
Project no. 2- seven segment interfacing and display
2
COMPANY PROFILE
HCL Technologies is an organization which is established in the field of
Network Support, Network training and Embedded systems. It provides support
and training in the field of networking solutions (CISCO, LINUX) and embedded
systems (Micro controller based design, Electronics system design).
HCL Technologies also provide Technical Research & Development support
and consultancy to some Electronics companies.
Network Training
a) CISCO CCNA, CCNP
4
EMBEDDED SYSTEM
What is Embedded System?
Embedded system employs a combination of software & hardware to
perform a specific function. It is a part of a larger system which may not be a
computerWorks in a reactive & time constrained environment.
Any electronic system that uses a CPU chip, but that is not a general-purpose
workstation, desktop or laptop computer is known as embedded system. Such
systems generally use microprocessors; microcontroller or they may use
custom-designed chips or both. They are used in automobiles, planes, trains,
space vehicles, machine tools, cameras, consumer and office appliances, cell
phones, PDAs and other handhelds as well as robots and toys. The uses are
endless, and billions of microprocessors are shipper every year for a myriad of
applications.
In embedded systems, the software is permanently set into a read-only memory
such as a ROM or flash memory chip, in contrast to a general-purpose computer
that loads its programs into RAM each time. Sometimes, single board and rack
mounted general-purpose computers are called "embedded computers" if used
to cont
DISADVANTAGES OF MICROPROCESSORS
OVER MICROCONTROLLERS
System designed using Microprocessors are bulky
They are expensive than Microcontrollers
7
There are two types of Microcontroller architecture designed for embedded system
development. These are:
1)RISC- Reduced instruction set computer
2)CISC- Complex instruction set computer
PIC
MICROCONTROLLER
PIC 16 SERIES-PIC16F77A
FIG.1
PIC is a family of Harvard architecture microcontrollers made by Microchip
Technology, derived from the PIC1640 originally developed by General
Instrument's Microelectronics Division. The name PIC initially referred to
"Peripheral Interface Controller".
It is available in different configurations viz 8bit,16 bit,32 bit with instructions set
as given below :
Under 8 bit comes-PIC10 xxxx, PIC12 xxxx, PIC16 xxxx, PIC18 xxxx.(12 bit
instruction set)
10
Peripheral Features:
Timer0: 8-bit timer/counter with 8-bit prescaler.
Timer1: 16-bit timer/counter with prescaler, can be incremented during SLEEP
via external crystal/clock.
Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler.
Two Capture, Compare, PWM modules
- Capture is 16-bit, max. resolution is 12.5 ns
- Compare is 16-bit, max. resolution is 200 ns
- PWM max. resolution is 10-bit.
8-bit, up to 8-channel Analog-to-Digital converter.
Synchronous Serial Port (SSP) with SPI (Master mode) and I2C(Slave).
Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI).
Parallel Slave Port (PSP), 8-bits wide with external RD, WR and CS controls
(40/44-pin only).
Brown-out detection circuitry for Brown-out Reset (BOR).
CMOS Technology:
Low power, high speed CMOS FLASH technology.
Fully static design.
Wide operating voltage range: 2.0V to 5.5V.
High Sink/Source Current: 25 Ma.
Industrial temperature range.
Low power consumption:
- < 2 mA typical @ 5V, 4 MHz
12
PIN DIAGRAM
FIG.2
13
PIN DESCRIPTION
14
15
16
CORE ARCHITECTURE
17
A single accumulator (W), the use of which (as source operand) is implied
(i.e. is not encoded in the opcode)
All RAM locations function as registers as both source and/or destination of
math and other functions.
A hardware stack for storing return addresses
A fairly small amount of addressable data space (typically 256 bytes),
extended through banking
Data space mapped CPU, port, and peripheral registers
The program counter is also mapped into the data space and writable (this is
used to implement indirect jumps).
Unlike most other CPUs, there is no distinction between memory space and
register space because the RAM serves the job of both memory and registers, and
the RAM is usually just referred to as the register file or simply as the registers
18
ELECTRICAL CHARACTERISTICS
Absolute Maximum Ratings
Ambient temperature under bias...................................... .-55 to +125C
Storage temperature.................................................... -65C to +150C
Voltage on any pin with respect to VSS (except VDD, MCLR. and
RA4) ......................................... -0.3V to (VDD + 0.3V)
Voltage on VDD with respect to VSS............................. -0.3 to +6.5V
Voltage on MCLR with respect to VSS (Note2)..........................0 to +13.5V
Voltage on RA4 with respect to Vss ..................................0 to +12V
Total power dissipation (Note 1)................................................1.0W
Maximum current out of VSS pin................................................300 mA
Maximum current into VDD pin .....................................................250 mA
Input clamp current, IIK (VI < 0 or VI > VDD)............................ 20 mA
Output clamp current, IOK (VO < 0 or VO > VDD) ...................... 20 mA
Maximum output current sunk by any I/O pin..................................25 mA
Maximum output current sourced by any I/O pin ............................25 mA
19
20
PROGRAMMING OF PIC
COMPILER USED-
mikroC
Introduction to mikroC
mikroC is a powerful, feature rich development tool for PICmicros. It is designed
to provide the programmer with the easiest possible solution for developing
applications for embedded systems, without compromising performance or control.
21
FIG.4
mikroC IDE
PIC and C fit together well: PIC is the most popular 8-bit chip in the world, used in
a wide variety of applications, and C, prized for its efficiency, is the natural choice
for developing embedded systems. mikroC provides a successful match featuring
highly advanced IDE, ANSI compliant compiler, broad set of hardware libraries,
comprehensive documentation, and plenty of ready-to-run examples.
22
Features
mikroC allows you to quickly develop and deploy complex applications:
Write your C source code using the built-in Code Editor (Code and
Parameter Assistants, Syntax Highlighting, Auto Correct, Code Templates,
and more)
Use the included mikroC libraries to dramatically speed up the development:
data acquisition, memory, displays, conversions, communications
Practically all P12, P16, and P18 chips are supported.
Monitor your program structure, variables, and functions in the Code
Explorer.
Generate commented, human-readable assembly, and standard HEX
compatible with all programmers.
Inspect program flow and debug executable logic with the integrated
Debugger.
Get detailed reports and graphs: RAM and ROM map, code statistics,
assembly listing, calling tree, and more
We have provided plenty of examples for you to expand, develop, and use as
building bricks in your projects. Copy them entirely if you deem fit thats
why we included them with the compiler.
Projects
mikroC organizes applications into projects, consisting of a single project file
(extension .ppc) and one or more source files (extension .c). You can compile
source files only if they are part of a project.
The project file carries the following information:
project name and optional description,
target device,
device flags (config word),
23
device clock,
FIG.5
New Project
The easiest way to create project is by means of New Project Wizard, drop-down
menu Project New Project. Just fill the dialog with desired values (project name
and description, location, device, clock, config word) and mikroC will create the
appropriate project file . Also, an empty source file named after the project will be
created by default. mikroC does not require you to have source file named same as
the project, its just a matter of convenience.
Edit Project
Later, you can change project settings from the drop-down menu Project Edit
Project. You can rename the project, modify its description, change chip, clock,
config word, etc.
24
To delete a project, simply delete the folder in which the project file (extension
.ppc) is stored.
Add/Remove Files from Project
A project can contain any number of source files (extension .c). The list of relevant
source files is stored in the project file (extension .ppc).
To add source file to your project, select Project Add to Project from the dropdown menu, or click the Add to Project Icon
. Each added source file must
be self-contained, i.e. it must have all the necessary definitions after preprocessing.
To remove file(s) from your project, select Project Remove from Project from the
drop-down menu, or click the Remove from Project Icon
.
Note: For inclusion of the header files (extension .h), use the preprocessor directive
#include. See File Inclusion for more information.
Extended functionality of the Project Files tab
By using the Project Files' new features, you can reach all the output files (.lst,
.asm) by a single click. You can also include in project the library files (.mcl), for
libraries, either your own or compiler default, that are project-specific.
Libraries (.mcl) now have different, more compact format, compared to mikroC
version 2. This, however, means that library formats are now incompatible. The
users that are making transition from version 2 to 5, must re- build all their
previously written libraries in order to use them in the new version. All the source
code written and tested in previous versions should compile correctly on version
5.0, except for the asm{} blocks, which are commented in the asm section of help.
Project Level Defines:
Project Level Defines(.pld) files can also be added to project. Project level define
files enable you to have defines that are visible in all source files in the project. A
file must contain one definition per line in the following form:
25
<symbol>[=[<value>]]
<symbol (a,b)>[=[<value>]]
Define a macro named symbol. To specify a value, use =<value>. If =<value> is
omitted, 1 is assumed. Do not enter white-space characters immediately before
"=". If a white- space character is entered immediately after "=", the macro is
defined as zero token. This option can be specified repeatedly. Each appearance of
symbol will be replaced by the value before compilation.
There are two predefined project level defines see predefined project level defines..
Programs get a formal structure and can be divided into separate functions.
Programming and program test time is drastically reduced, this increases
efficiency.
Keywords and operational functions can be used that come closer to how
humans think.
The supplied and supported C libraries contain many standard routines such as
numeric conversions.
Reusable code: Existing program parts can be more easily included into new
programs, because of the comfortable modular program construction
techniques.
The C language based on the ANSI standard is very portable. Existing
programs can be quickly adapted to other processors as needed.
PROJECT NO-1
FIG.6
the interfacing of LED is shown in the figure above.it is given Vcc through
resistors of 330E.
also a darlington pair IC is also used i.e.ULN 2803 which shift the dc level of
volage coming from port of pic microcontroller.
Now to glow the desired LED ,proper hexadecimal code for its binary is
programmed in pic.eg.to glow alternative LEDs the binary code will be10101010
and its corresponding hexadecimal code will be 0xAA.
So,0xAA is fed to controller with coding.
Also PIC has a internal TRIS register which controls the flow of insructions from
the corresponding port i.ee PORT will behave as input(if =1) and as output(if=0).
28
void main()
{
PORTC = 0;
TRISC = 0;
// Initialize PORTC
// Configure PORTC as output
while(1)
{
PORTC = OxAA;
Delay_ms(1000);
}}
Thus LED Blinking practical is done sucessfully.
PROJECT NO-2
SEVEN SEGMENT INTERFACING AND DISPLAY
A Seven segment display consists of seven LEDs arranged in pattern of digit like
8.
29
FIG.8
We use a bcd to seven segment decoder which saves pin of microcontroller from
seven(one for each Led) to four.So we have to give bcd code for desired digit to be
displayed on it.
30
Now also we can display more then one seven segment display simultaneously.but
it will take a number of pins of controller.So we use two pins from controller to
control the display of seven segment one by one from same port such that it
appears to be displaying simultaneously.
Tdis is done by providing a very small delay such that our eyes cant even detect
the change over from one display to another.
CODING FOR DISPLAY
void main()
{
TRISB=0xf0;
TRISC=0xf0;
PORTC=0x00;
while(1)
{
PORTB=0x00 ;
//code for 0
delay_ms(1000);
PORTB=0x08 ;
//code for 1
31
delay_ms(1000);
PORTB=0x04 ;
//code for 2
delay_ms(1000);
PORTB=0x0c ;
//code for 3
delay_ms(1000);
PORTB=0x02 ;
//code for 4
delay_ms(1000);
PORTB=0x09 ;
//code for 5
delay_ms(1000);
PORTB=0x06 ;
//code for 6
delay_ms(1000);
PORTB=0x0e ;
//code for 7
delay_ms(1000);
32
PORTB=0x01 ;
//code for 8
delay_ms(10000);
PORTB=0x09 ;
//code for 9
delay_ms(10000);
}
}
the above program will display 0 to 9 on one seven segment display with a delay of
one second between it.\
NOW TO DISPLAY ON FOUR DISPLAYS CONNECTED..
CODE IS
void main()
{
TRISB=0xf0;
TRISC=0xf0;
PORTC=0x00;
while(1)
{
PORTB=0x00 ;
//code for 0
33
PORTC=0xfe ;
delay_ms(100);
PORTB=0x08 ;
PORTC=0xfd ;
//code for 1
//DISPLAYS ON SECOND 11111101
delay_ms(100);
PORTB=0x04 ;
PORTC=0xfb ;
//code for 2
//DISPLAYS ON THIRD 11111011
delay_ms(100);
PORTB=0x0C ;
PORTC=0xf7 ;
//code for 3
//DISPLAYS ON FIRST 11110111
delay_ms(100);
}
}
Thus program for both single seven segment and multiple seven segment displays
has been studied.
34
PROJECT NO-3
INTERFACING AND CONTROL OF STEPPER MOTOR WITH
PIC 16F77A
FIG.7
35
Stepper motor are those which rotates in steps.like all motors it is also based on
electromagnetic induction i.e. electric field produces a magnetic field whose
variation causes a torque which rotates the motor.
A stepper motor is a brushless, synchronous electric motor that can divide a full
rotation into a large number of steps. The motor's position can be controlled
precisely, without any feedback mechanism (see open loop control). Stepper
motors are similar to switched reluctance motors, which are very large stepping
motors with a reduced pole count, and generally are closed-loop commutated.
Fundamentals of Operation
Stepper motors operate much differently from normal DC motors, which rotate
when voltage is applied to their terminals. Stepper motors, on the other hand,
effectively have multiple "toothed" electromagnets (a.k.a. phases) arranged around
a central gear-shaped piece of iron. The electromagnets are energized by an
external control circuit, such as a microcontroller. To make the motor shaft turn,
first one electromagnet is
given power, which makes the gear's teeth magnetically attracted to the
electromagnet's teeth. When the gear's teeth are thus aligned to the first
electromagnet, they are slightly offset from the next electromagnet. So when the
next electromagnet is turned on and the first is turned off, the gear rotates slightly
to align with the next one, and from there the process is repeated. Each of those
slight rotations is called a "step." In that way, the motor can be turned a precise
angle.
36
Now to run the motor we have to feed the binary code to turn on the current of that
winding
For pair 1st-00000011(binary)-0x03
For pair 2nd-00000110(binary)-0x06
For pair 3rd -000001100(binary)-0x0c
For pair 4th -00011000(binary)-0x09
CODE IS
void forward();
void reverse();
int i;
void main()
{
TRISB=0xf0;
PORTB=0x00;
while(1)
{
forward();
delay_ms(400);
reverse();
37
delay_ms(400);
}
}
void forward()
{
for(i=0;i<=50;i++)
{
PORTB=0x03;
delay_ms(70);
PORTB=0x06;
delay_ms(70);
PORTB=0x0c;
delay_ms(40);
PORTB=0x09;
delay_ms(40);
}
}
void reverse()
38
{
for(i=0;i<=50;i++)
{
PORTB=0x09;
delay_ms(40);
PORTB=0x0c;
delay_ms(40);
PORTB=0x06;
delay_ms(40);
PORTB=0x03;
delay_ms(40);
}
}
The above code will rotate the motor first in forward direction and then in reverse
direction.
Thus,stepper motor has been studied successfully.
39
PROJECT NO-4
LCD INTERFACING AND DISPLAY
FIG.8
LCD stands for Liquid Crystal Display.to run it via PIC 16F77A,we need
command signals and vcc to drive it.now the signal that is required to display
character is produced by an IC which is already embedded on it.its name is
HD44780.
HD44780+LCD=an intelligent controller.
The function of each of the connections is shown in the table below:Pins 1 & 2 are the power supply lines, Vss & Vdd. The Vdd pin should be connected
to the positive supply & Vss to the 0V supply or ground.
40
Although the LCD module data sheets specify 5V D.C. supply (at only a few
milliamps), supplies of 6V & 4.5V both work well, and even 3V is sufficient for some
modules. Consequently, these modules can be effectively and economically powered
by batteries.
Pin 3 is a control pin, Vee, which is used to alter the contrast of the display. Ideally,
these pin should be connected to a variable voltage supply. A preset potentiometer
connected between the power supply lines, with its wiper connected to the contrast pin
is suitable in many cases, but be aware that some modules may require a
negative potential; as low as 7V in some cases. For absolute simplicity, connecting
this pin to 0V will often suffice.
PIN NO.
NAME
FUNCTION
Vss
Ground
Vdd
+ve supply
Vee
contrast
41
RS
Register select
R/W
Read/Write
Enable
D0
Data Bit 0
D1
Data Bit 1
D2
Data Bit 2
10
D3
Data Bit 3
11
D4
Data Bit 4
12
D5
Data Bit 5
13
D6
Data Bit 6
14
D7
Data Bit 7
Three command control inputs. When this line is low, data bytes transferred to the
display are treated as commands, and data bytes read from the display indicate its
status. By setting the RS line high, character data can be transferred to and from
the module.
42
Pin 5 is (R/W) line. This line is pulled low in order to write commands or
character data to the module, or pulled high to read character data or status
information from its registers.
Pin 6 is Enable (E) line. This input is used to initiate the actual transfer of
commands or character data between the module and the data lines. When writing
to the display, data is transferred only on the high to low transition of this signal.
However, when reading from the display, data will become available shortly after
the low to high transition and remain available until the signal falls low again.
Pins 7 to 14 are the eight data bus lines (D0 to D7). Data can be transferred to
and from the display, either as a single 8-bit byte or as two 4-bit nibbles. In the
latter case, only the upper four data lines (D4 to D7) are used. This $-bit mode is
beneficial when using a microcontroller, as fewer I/O lines are required.
Connections are shown as below in fig 9.
FIG.9
CODING
void main()
43
{
TRISB = 0;
// PORTB is output
Lcd_Init(&PORTB);
Lcd_Cmd(Lcd_CLEAR);
// Clear display
// PORTB is output
44
Lcd_Init(&PORTB);
Lcd_Cmd(Lcd_CLEAR);
// Clear display
Lcd_Out(2, 5,text1);
while(1)
{
Lcd_Cmd(LCD_SHIFT_LEFT);
delay_ms(1000);
}
It will shift the character to the left with a delay of 1 sec between it.
Thus LCD display and scroll is studied successfully.
PROJECT NO-5
BUILT IN ADC OF PIC16F77A(TEMPERATURE MONITORING)
45
46
FIG.10
R/W-0
R/W-0
R/W-0
CHS1
R/W-0
CHS0
47
R/W-0
U-0
R/W-0
GO/DON
E
--------
ADON
bit 7
bit 0
U-0
ADFM
ADCS2
U-0
U-0
U-0
R/W-0
PCFG3
48
R/W-0
PCFG2
R/W-0
PCFG1
PCFG0
00FOSC/2
01FOSC/8
10FOSC/32
11FRC (clock derived from the internal A/D RC oscillator)
49
void main()
{
51
INTCON = 0;
TRISB = 0;
Lcd_Init(&PORTB);
LCD_Cmd(LCD_CURSOR_OFF);
LCD_Cmd(LCD_CLEAR);
text = "hcl";
LCD_Out(1,1,text);
text = "LCD example";
LCD_Out(2,1,text);
ADCON1
TRISA
= 0x82;
= 0xFF;
text = "voltage:";
while (1)
{
delay_ms(300) ;
adc_rd = ADC_read(0);
LCD_Out(2,1,text);
ch
= tlong / 1000;
LCD_Chr(2,9,48+ch);
LCD_Chr_CP('.');
ch
LCD_Chr_CP(48+ch);
ch
LCD_Chr_CP(48+ch);
ch
= tlong % 10;
LCD_Chr_CP(48+ch);
LCD_Chr_CP('V');
delay_ms(3000) ;
delay_ms(1);
}
}
53
PROJECT NO-6
TO STUDY SWITCHING ACTION OF PIC PINS.
As in AT89s51,the way of addressing pins is by p0.0,p0.1..so on.
Similarly in PIC it is possible to address pins using
Syntax: PORT( NAME).F(0 to 7)
Now pin can be put ON or OFF according to via resistor.
Internally,when pin is high its flip flop is sat.when external switch is closed ,it
forces no current or voltage to enter to pin and also lowers the pin from 1 to 0.
54
Thus when switch is pressed ,the pin becomes zero.so ,implementing this in
practical.The swiches whose one end are connected to pins of nontroller are shown
FIG.11
#define s0 PORTC.F0
#define s1 PORTC.F1
55
#define s2 PORTC.F2
#define s3 PORTC.F3
#define s4 PORTC.F4
void main()
{
TRISB=0x00; \\ PORT B AS OUTPUT
TRISC=0xff;
\\PORT C as input
PORTC=0xff;
do
{
if(s0==0)
{
PORTB=0x80; \\1st LED glows
delay_ms(600);
}
if(s1==0)
{
PORTB=0x40;
delay_ms(600);
}
if(s2==0) \\3rd switch is pressed
{
PORTB=0x20;
delay_ms(600);
}
if(s3==0)
{
PORTB=0x10;
delay_ms(600);
}
else
{
PORTB=0xff;
}}
while(1);
}
Thus switching action is studied.
57
PROJECT NO-7
While if it is desired to have more options for a pin,a matrix is formed in which
row and column are made such that each pin can contol more than one switch or
vice versa.
The coding for keyboard (4*4) matrix is as follows:
#define row0 PORTC.F0
#define row1 PORTC.F1
#define row2 PORTC.F2
#define row3 PORTC.F3
#define col0 PORTC.F4
#define col1 PORTC.F5
#define col2 PORTC.F6
#define col3 PORTC.F7
void main()
{
TRISB=0x00;
TRISC=0xff;
PORTC=0xff;
LCD_INIT(&PORTB);
LCD_OUT(1,1,"SWITCH=");
do
59
{
LCD_OUT(1,8," ");
if(row0==0 && col0==0)
{
lcd_out(1,8,"k0");
delay_ms(600);
}
if(row0==0 && col1==0)
{
lcd_out(1,8,"k1");
delay_ms(600);
}
if(row0==0 && col2==0)
{
lcd_out(1,8,"k2");
delay_ms(600);
}
if(row0==0 && col3==0)
{
60
lcd_out(1,8,"k3");
delay_ms(600);
}
if(row1==0 && col0==0)
{
lcd_out(1,8,"k4");
delay_ms(600);
}
if(row1==0 && col1==0)
{
lcd_out(1,8,"k5");
delay_ms(600);
}
if(row1==0 && col2==0)
{
lcd_out(1,8,"k6");
delay_ms(600);
}
if(row1==0 && col3==0)
61
{
lcd_out(1,8,"k7");
delay_ms(600);
}
if(row2==0 && col0==0)
{
lcd_out(1,8,"k8");
delay_ms(600);
}
}
if(row2==0 && col3==0)
{
lcd_out(1,8,"k11");
delay_ms(600);
}
else
{Lcd_out(1,8,"
");}
}
while(1);
}
Thus,the keyboard matrx practical is performed.
PROJECT NO-8
SERIAL COMMUNICATION(B/W PC ANDMICROCONTROLLER)
To send data via single line through a bit stream is known as serial communication.
Reception is of type SIPO-Serial Input Parallel Output.
Transmission is of type PISO-Parallel Input Serial Output.
63
FIG.12
PIC has two buffers and it allows full duplex communication.to change settings we
have to re configure TXSTA register
The Universal Synchronous Asynchronous Receiver Transmitter (USART) module
is one of the two serial I/O modules. (USART is also known as a Serial
Communications Interface or SCI.) The USART can be configured
as a full duplex asynchronous system that can communicate with peripheral
devices, such as CRT terminals and personal computers, or it can be configured as
a half duplex synchronous system that can communicate with peripheral devices,
such as A/D or D/A integrated
circuits, serial EEPROMs, etc.
The USART can be configured in the following modes:
64
CSRC
R/W-0
TX9
R/W-0
TXEN
R/W-0
U-0
SYNC
R/W-0
R-1
BRGH
R/W-0
TRMT
TX9D
Now coding
1).to transmit data..
void main()
{
usart_init(2400);
while(1)
{
usart_write('s');
66
usart_write('a');
usart_write('g');
usart_write('a');
usart_write('r');
delay_ms(600);
}
}
2).to transmit as well as read
unsigned int i;
void main()
{
usart_init(2400);
while(1)
{
if(usart_data_ready() )
{
i= usart_read();
usart_write('i');
}
67
usart_write('s');
usart_write('a');
usart_write('g');
usart_write('a');
usart_write('r');
delay_ms(600);
}
3). To send an array
unsigned char arr[] =("sagar$");
void display(unsigned char*s);
void main()
{
Usart_Init(2400);
while(1)
{
display(arr);
delay_ms(600);
}
68
}
void display(unsigned char*s)
{
while(*s!='$')
{
usart_Write(*s);
delay_ms(10);
s++;
}
}
Thus serial communication has been studied successfully.
BIBLIOGRAPHY
Wikipedia
MicroC Manuals
www.talkingelectronics.com
www.howstuffworks.com
The Art of Electronics (Book)
69