Fakulti Teknologi Kejuruteraan Universiti Teknikal Malaysia Melaka
Fakulti Teknologi Kejuruteraan Universiti Teknikal Malaysia Melaka
Fakulti Teknologi Kejuruteraan Universiti Teknikal Malaysia Melaka
EMBEDDED SYSTEMS
NAME OF GROUP 1.
MEMBERS &
MATRIX NUMBER
2.
3.
COURSE
DATE
NAME OF INSTRUCTOR 1.
2.
TOTAL MARKS
1.0 OBJECTIVES
Familiarize the students with MPLAB X IDE and XC8 compiler for PIC based embedded
systems design.
Construct basic embedded hardware interfacing by using PROTEUS ISIS
Perform program debugging through PIC memory access features in ISIS.
To understand basic serial communication in embedded system and perform Interrupt
service routine for serial communication.
Analyze serial communication signal for different speed.
2.0 EQUIPMENT/COMPONENTS
Personal Computer
MPLAB X Integrated Development Environment
Microchip XC8 Compiler
PROTEUS ISIS Software
Eltima Virtual Serial Port Driver
RealTerm Serial Communication Software
Serial communication is very important features in embedded system. It helps the system to
communicate with external devices due insufficient human machine interface in embedded system.
Because of that developer need to interface their embedded system with a PC during development
and/or during testing in the field. The advantages of using serial communication is because the
number of pins required is lower that parallel communication. Serial communication in embedded
system capable to communicate to other peripherals just one I/O pin, compared to eight or more
for parallel communications. Many common embedded system peripherals, such as ADC and DAC
converters, LCDs, and temperature sensors also support serial interfaces.
Universal Synchronous Asynchronous Receiver Transmitter (USART) is a common serial
communication module embedded in microcontroller. It help microcontroller to communicate with
Page 2 of 8
JTKEK/BETC 4473
external devices such as PC, GSM modems, Bluetooth modules and other peripherals with
additional interfacing circuit.
Figure 3.2: Typical USART Data Frame ASCII Character (59h) at 9600 Baud Per Second
The following table illustrate the formula for baud rate calculation:
Calculation for high speed asynchronous 8 bit communication at 9600 speed for 8 MHz Oscillator:
High speed, BRGH = 1, so we choose formula for baud rate calculation as:
(n+1) = 8M/(9600*16)
n = 51
So, SPBRG = 51 and BRGH = 1 need to be set for high speed serial communication at 9600.
Page 3 of 8
JTKEK/BETC 4473
4.0 PROCEDURE
6. You may need to adjust the time/div and voltage/div setting to properly view the
whole character sent serially through Tx pin.
7. What is the value of the signal sent at Tx pin in Hexadecimal?
8. Modify the main.c file to transmit 3 different ASCII character and repeat step 5 and
6 for each character.
9. Record your observation and identify the bits represented by the signal recorded in
the virtual oscilloscope.
1. Modify the content of while loop in main.c file to receive data and transmit back the
data sent through pin Tx of PIC18F4550 as in the following code:
while(1)
{
if(bDataFetched)
{
int cnt=0;
putsUSART(RxMessageBuffer);
i=0;
Lcd_Clear();
Lcd_Set_Cursor(1,1);
Lcd_Write_String(RxMessageBuffer);
bDataFetched=0;
clearRxMsgBuf();
}
}
Page 4 of 8
JTKEK/BETC 4473
2. Use RealTerm software to send the data from computer to the simulation in Proteus
ISIS. Please refer the setting of virtual serial port pair driver installed in the Device
Manager.
3. Please ensure the right setting in the COMPIM component and the RealTerm serial
port configuration. Then Click on button Change.
Page 5 of 8
JTKEK/BETC 4473
5. Send 4 characters as illustrated in Figure 4.5 and click Send Numbers. Capture the
signal sent to the PIC using virtual oscilloscope. You may use the One-Shot trigger
function by pressing the button One-Shot at the Trigger Menu of the virtual
oscilloscope. The One-Shot trigger will freeze the oscilloscope display when any
changes on voltage level on the input signal.
6. Based on step 5, analyze the signal, which character sent first and compare with
the display in RealTerm. (You can view the data sent to the RealTerm as ASCII or
Hexadecimal).
7. Send the following ASCII character according to the sequence listed and explain
your observation. Does PIC reply back after each sequence?
REMINDER
1. Double click on PIC18F4550 component and locate the hex file obtained in step 14
of Part 1. Set the clock frequency to 20MHz. Please save your ISIS design file
before you start the simulation.
Page 6 of 8
JTKEK/BETC 4473
5.0 DISCUSSION/QUESTIONS
1. Based data observed in explain how the character/data converted into voltage level.
Validate the bit duration for 1 bit by using the calculated value and the observe
value.
2. Calculate the appropriate SPBRG (baud variable) value for the system to
communicate at 57600 bps.
3. Modify the code in main.c file in Part 2 to enable the system to communicate at the
speed of 57600 bps. Without changing the RealTerm Serial Port Configuration,
explain what happens when you send character ‘A’, does the RealTerm display the
sent data by PIC correctly?
4. Explain do we need to configure same baudrate at receiver and transmitter side?
5. Explain the operation in the SerialRxPinInterrupt() function.
6. What is the character used as serial data termination character in the function?
7. Modify the code to toggle pin RA4 value 0 to1 when complete last received and 1 to
0 when it echo the character back to RealTerm software. Measure the time between
ising edge and falling edge to indicate the processing time.
8. What is the average processing time for 1 character (sent to PIC and transmit back
ealTerm)?
6.0 CONCLUSION
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
Page 7 of 8
JTKEK/BETC 4473
APPENDIX 1
A
VCC
B
U1 C4
10u
15 2
P1 RC0/T1OSO/T1CKI RA0/AN0
16 3
RC1/T1OSI/CCP2/UOE RA1/AN1
17 4
RC2/CCP1/P1A RA2/AN2/VREF-/CVREF
1 23 5
DCD RC4/D-/VM RA3/AN3/VREF+
DSR
6 24
RC5/D+/VP RA4/T0CKI/C1OUT/RCV
6 C1
2 25 7
RXD RC6/TX/CK RA5/AN4/SS/LVDIN/C2OUT
7 26 14
RTS RC7/RX/DT/SDO RA6/OSC2/CLKO
3 13
TXD OSC1/CLKI
8
CTS 22p
DTR
4
VCC
19
RD0/SPP0 RB0/AN12/INT0/FLT0/SDI/SDA
33 X1
9 20 34 CRYSTAL
RI RD1/SPP1 RB1/AN10/INT1/SCK/SCL
RS
21
RD2/SPP2 RB2/AN8/INT2/VMO
35 C2
22 36
E RD3/SPP3 RB3/AN9/CCP2/VPO
27 37
ERROR D4 RD4/SPP4 RB4/AN11/KBI0/CSSPP
28 38
D5 RD5/SPP5/P1B RB5/KBI1/PGM
COMPIM 29 39
D6 RD6/SPP6/P1C RB6/KBI2/PGC 22p
LCD1 R1 D7
30
RD7/SPP7/P1D RB7/KBI3/PGD
40
10k
LM016L 8
RE0/AN5/CK1SPP
9
RE1/AN6/CK2SPP
10
RE2/AN7/OESPP
1 18
RE3/MCLR/VPP VUSB
PIC18F4550
VDD
VSS
VEE
RW
RS
D0
D1
D2
D3
D4
D5
D6
D7
E
1
2
3
4
5
6
7
8
9
10
11
12
13
14
RS
D4
D5
D6
D7
Page 8 of 8