Sie sind auf Seite 1von 70

SEC - ECE EMBEDDED SYSTEMS LAB RECORD

PROGRAM - LED blinking


#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
int main(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_8MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7);
unsigned long count;
while(1)
{
GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_5, 0);
for(count=0;count<200000;count++)
{
}
GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_5, GPIO_PIN_5);
for(count=0;count<200000;count++);
}
}
PROGRAM RGB Pattern
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
int main(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_8MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7);
GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7, 0);
unsigned long count;
while(1)
{
GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_5, 0);
for(count=0;count<200000;count++)
{C
GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_5, GPIO_PIN_5);
for(count=0;count<200000;count++);
}
}

1
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

EX NO: DATE:

VERIFICATION AND VALIDATION USING OPEN SOURCE SOFTWARE

AIM
To verify and validate the given applications using industry standard open source
ECLIPSE IDE.
LED blinking, RGB Pattern, Switch, UART and PLL
TOOLS REQUIRED:

S.NO Name Type

1 Eclipse IDE

2 LM Flash Programmer

3 GNU Make ARM Tool Chain

4 Stellaris Ware Driver library

5 FTDI VCP USB Driver

HARDWARE REQUIRED:

S.NO Name Type Quantity

1 CortexM3-LM3S608 C Microcontroller kit 1

ALGORITHM LED blinking

Include the necessary header files.


Select the Clock divider value, oscillator type selection and frequency by using
SysCtlClockSet function.
Enable the system control for peripheral GPIO Port C using SysCtlPeripheralEnable
function.
Configure the Port C Pins 5, 6 and 7 as output using GPIOPinTypeGPIOOutput
function.(Refer appendix c for circuit diagram)
Based on the application, write the necessary logic value on the port pins using
GPIOPinWrite function.
Call the delay function whenever needed.

2
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

PROGRAM Switch
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
int main(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_8MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7);
GPIOPinTypeGPIOInput(GPIO_PORTE_BASE,GPIO_PIN_0);
GPIOPinTypeGPIOInput(GPIO_PORTE_BASE,GPIO_PIN_1);
GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA,
GPIO_PIN_TYPE_STD_WPU);
GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_1, GPIO_STRENGTH_2MA,
GPIO_PIN_TYPE_STD_WPU);
GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7,
GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7);
while(1)
{
if(GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_0)==GPIO_PIN_0)
{
GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_6, GPIO_PIN_6);
}
if(GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_1)==GPIO_PIN_1)
{
GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_5, GPIO_PIN_5);
}
if(GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_0)==0)
{
GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_6, 0);
}
if(GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_1)==0)
{
GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_5, 0);
}
}
}

3
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

ALGORITHM RGB Pattern


Include the necessary header files.
Select the Clock divider value, oscillator type selection and frequency by using
SysCtlClockSet function.
Enable the system control for peripheral GPIO Port C using SysCtlPeripheralEnable
function.
Configure the Port C Pins 5, 6 and 7 as output using GPIOPinTypeGPIOOutput function.
Based on the application, write the necessary logic value on the port pins using
GPIOPinWrite function.
Call the delay function whenever needed.
ALGORITHM Switch
Include the necessary header files.
Select the Clock divider value, oscillator type selection and frequency by using
SysCtlClockSet function.
Enable the system control for peripheral GPIO Port C using SysCtlPeripheralEnable
function.
Configure GPIO pad with internal pull-up enabled, check with GPIO_PIN_0 |
GPIO_PIN_1.
Set the logic 1 on GPIO Port C Pins 5, 6, 7 to off all LEDs using GPIO Write function
Inside infinite loop, check if GPIO_PIN_0= 1 then make GPIO_PIN_6=1 and if
GPIO_PIN_1=1 then make GPIO_PIN_5=1 and if GPIO_PIN_0= 0 then make
GPIO_PIN_6=0 and if GPIO_PIN_1=0 then make GPIO_PIN_5=0.
ALGORITHM UART
Include the necessary header files.
Select the Clock divider value, oscillator type selection and frequency by using
SysCtlClockSet function.
Enable the system control for peripheral GPIO Port C and UART0 using
SysCtlPeripheralEnable function.
Make the UART pins be peripheral controlled.
Set the type of the UART Pins.
Set the configuration of a UART. Initialize GPIO Pins 5, 6, 7 on PORT C to 0.
Inside infinite loop, check for characters availability in port. If yes, then at the receiving end
we can see the character, which is next to the character that is typed on the transmitting end.

4
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

PROGRAM UART
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
int main(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
UARTConfigSetExpClk(UART0_BASE,
8000000, 115200,(UART_CONFIG_ WLEN _8 |
UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
while(1)
{
if(UARTCharsAvail(UART0_BASE))
{
UARTCharPut(UART0_BASE,(unsigned char)(UARTCharGet(UART0_BASE)+1));
}}}
PROGRAM PLL
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "driverlib/interrupt.h"
#include "utils/uartstdio.h"
void UartInit(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
UARTStdioInit(0);
}
int main(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_8MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7);
GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7,
GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7);
UartInit();
while(1)
{
UARTprintf("Oscillator used= %4d\r", SysCtlClockGet());
GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7,
GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7);
SysCtlDelay(SysCtlClockGet() / 12);
GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7, 0);
SysCtlDelay(SysCtlClockGet() / 12);
}}
5
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

ALGORITHM PLL

Include the necessary header files.


Inside UartInit function, enable GPIO port A which is used for UART0 pins and then,
Make the UART pins be peripheral controlled and Initialize the UART for console I/O.
Select the Clock divider value, oscillator type selection and frequency by using
SysCtlClockSet function.
Enable the system control for peripheral GPIO Port C and UART0 using
SysCtlPeripheralEnable function.
Set the type of the GPIO Pins.
Initialize GPIO Pins 5, 6, 7 on PORT C to 0.
Call for UartInit function for configuring UART.
Get the system clock frequency by using SysCtlClockGet() and print it.
Make pin 5,6,7 high and go for system control delay.
Make pin 5,6,7 low and go for system control delay.

PROCEDURE

Goto File -> New -> C Project. Enter the project name. Select project type -> empty
project and select tool chain -> ARM Windows GCC (Sourcery G++ lite). Click Next.
Select Debug and Release. Then, press Finish.
Go to File -> Import -> General -> File System. Press Next.
Browse and select the project from Softwares_Stellaris. Press Finish.
Or
Create the source files namely main.c, startup_gcc.c, main.ld and readme.text by clicking
FILE-> NEW-> SOURCE FILE.
Go to Project Properties. Under C\C++ build -> settings -> Tool Settings -> target
processor -> choose cortex M3.
ARM Sourcery Windows GCC C Compiler -> preprocessor -> add source -> type gcc
and give ok.
ARM Sourcery Windows GCC C Compiler -> Directories.
add source -> file system -> select C:\stellarisware.,
add source -> file system -> select C:\stellarisware\driverlib.
add source -> file system -> select C:\stellarisware\utils.
add source -> file system -> select C:\stellarisware\inc.
Setting up code optimization -> select function sections.
Including the linker. ARM Sourcery Windows GCC C Linker -> General. Browse
main.ld file and select do not use standard start files, do not use default libraries and
remove unused sections.
Add the libraries. ARM Sourcery Windows GCC C Linker ->Libraries.
add source -> file system -> select C:\stellarisware.
add source -> file system -> select C:\stellarisware\driverlib\gcc_ cm3.
In the Project Properties window, go to C/C++ General -> Paths and Symbols -> Source
Location -> Link Folder.
Include the driverlib and utils folder that contain the C source files.
In the Project Properties window, go to C/C++ Build -> Settings -> Build Steps -> Post
Build Steps Command and type the following.
6
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

arm-none-eabi-objcopy -S -O binary "${ProjName}.elf "${ProjName}.bin


Click Apply and then click ok.
Develop the application in main.c file and then perform build operation.
Go to Run -> External Tools -> External Tools Configuration.
In the window, set the location to LMFlash.exe located under C:/Program Files/Texas
Instruments/ and click run.
After clicking Run, one window will pop up. In the configuration tab, choose the COM
port depending on the port the device is attached to.
Go to the Program tab, and select the .bin file by browsing to your project in the Eclipse
workspace folder. Make sure the address offset is 0800.
Connect the kit with the system and the press program. The application will get
downloaded into the kit. (Refer Appendix C)

Result:
Thus the above applications are verified and validated using open source eclipse IDE for
ARM Cortex M3 LM3s608 Microcontroller.

7
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

a) BUZZER

Port Pin No Description

P0.7 Buzzer
b) LED

LED No Port Pin No Description

1 P0.15 LED 8

2 P0.16 LED 7

3 P0.17 LED 6

4 P0.18 LED 5

5 P0.19 LED 4

6 P0.20 LED 3

7 P0.21 LE0 2

8 P0.22 LED 1

c) RELAY
Port Pin No Description

P1.26 Relay

d) 7 SEGMENT

Sl no Port Pin No Description

1 P1.16 A

2 P1.17 B

3 P1.18 C

4 P1.19 D

5 P1.20 E

6 P1.21 F

7 P1.22 G

8 P1.23 . (dp)H

9 P0.28 S1

10 P1.24 S2

11 P0.25 S3

12 P0.11 S4

8
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

EXNO: DATE:

HIGH LEVEL LANGUAGE PROGRAMMING AND PORTING


AIM
To write the C language program and porting it on the ARM 7 core for the following
interfacing
a) Buzzer,
b) LED,
c) Relay,
d) 7 segments LED,
e) 2x16 LCD,
f) ADC,
g) UART.

TOOLS REQUIRED:

S.NO Name Type

1 Triton IDE

2 Flash Fusion Fusing software

HARDWARE REQUIRED:

S.NO Name Type Quantity

1 ARM 7 - LPC 2148 Microcontroller kit 1

2 DC source (0-12)V 1

ALGORITHM:
a) BUZZER

Include the header file <LPC21XX.H>.


Include the header file <BOADR.H>.
Configure the Port 0 pins (P0.7) as GPI0 using Pin Selection one Register (PINSEL0).
Configure the Input Output Direction zero register (IODIR 0) for selecting output
operation of Port0 pin (P0.7)
To turn ON the Buzzer load the IOSET0 register value as 0x00000080
Call the Delay program.
To turn OFF the Buzzer load the IOCLR0 register value as 0x00000080

9
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

a) BUZZER
#include<LPC21xx.h>
#include<board.h>
void delay();
void main()
{
*IODIR0=0X00000080;
while (1)
{
*IOSET0 = 0X00000080; delay(); *IOCLR0= 0X00000080; delay();
}}
void delay()
{
int i,j;
for(i=1;i<15000;i++);
}

b) LED PROGRAM
#include<LPC21xx.h>
#include<BOARD.H>
void delay();
void main()
{
*IODIR0=0x007F8000;
while(1)
{
*IOSET0=0x007F8000; delay(); *IOCLR0=0x007F8000; delay();
} }
void delay()
{
unsigned int i,j;
for (i=1;i<150000;i++); }
C)RELAY PROGRAM
#include<LPC21xx.H>
#include<BOARD.H>
void delay();
void main()
{
*IODIR1=0x04000000;
while(1)
{
*IOSET1=0x04000000; delay(); *IOCLR1=0x04000000; delay();
}
}
void delay()
{
int i,j;
for(i=1;i<15000;i++);
for(j=0;j<15000;j++);
}

10
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

b)LED

Include the header file <LPC21XX.H>.


Include the header file <BOADR.H>.
Configure the Port 0 pins (P0.15 P0.22) as GPI0 using Pin Selection one Register
(PINSEL0).
Configure the Input Output Direction zero register (IODIR 0) for selecting output
operation of Port0 pin (P0.15 P0.22)
To turn ON the LEDs load the IOSET0 register value as logic one between the Port Pins
(P0.15 & P0.22
Call the Delay Program.
To turn OFF the LEDs load the IOCLR0 register value as logic one between the Port Pins
(P0.15 & P0.22

c) RELAY

Include the header file <LPC21XX.H>.


Include the header file <BOADR.H>.
Configure the Input Output Direction One register (IODIR 1) for selecting output
operation of Port1 pin (P1.26)
To turn ON the Relay load the IOSET1 register value as 0x04000000
Call the Delay Program.
To turn OFF the Relay load the IOCLR1 register value as0x04000000
d) 7 SEVEN SEGMENT

Include the header file <LPC21XX.H>.


Include the header file <BOADR.H>.
Configure the Input Output Direction One register (IODIR 1) for selecting output
operation of Port1 pins (P1.16 P1.23).
To display the hexadecimal number on the 7 segment display Load the corresponding
binary bit formats in the Port1 Input Output Set Register as 003F0000 (for zero)
Call the Delay Program.
To clear the displayed character ,on the 7 segment display, Load the corresponding
binary bit formats in the Port1 Input Output Clear Register as 003F0000 (for zero)

e) 2x16 LCD DISPLAY

11
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

d) 7 SEGMENT PROGRAM
#include<lpc21xx.h>
#include<BOARD.H>
void delay()
{
int i;
for(i=0;i<=200000;i++);
}
main()
{
*IOSET0 = 0x12000800; //select Seven Segment S1 ,S3,S4
//*IOSET1 = 0X01000000; //Select Seven Segment S2
*IODIR1=0X00FF0000;
while(1)
{
*IOSET1=0X003F0000; delay(); *IOCLR1=0X003F0000; delay();
*IOSET1=0X00060000; delay(); *IOCLR1=0X00060000; delay()
*IOSET1=0X005B0000; delay(); *IOCLR1=0X005B0000; delay();
*IOSET1=0X004F0000; delay(); *IOSET1=0X004F0000; delay();
*IOSET1=0X00660000; delay(); *IOCLR1=0X00660000; delay();
*IOSET1=0X006D0000; delay(); *IOCLR1=0X006D0000; delay();
*IOSET1=0X003C0000; delay(); *IOCLR1=0X003C0000; delay();
*IOSET1=0X00070000; delay(); *IOCLR1=0X00070000; delay();
*IOSET1=0X007F0000; delay(); *IOCLR1=0X007F0000; delay();
*IOSET1=0X00670000; delay(); *IOCLR1=0X00670000; delay();
*IOSET1=0X00770000; delay(); *IOCLR1=0X00770000; delay();
*IOSET1=0X007F0000; delay(); *IOCLR1=0X007F0000; delay();
*IOSET1=0X00390000; delay(); *IOCLR1=0X00390000; delay();
*IOSET1=0X003F0000; delay(); *IOCLR1=0X003F0000; delay();
*IOSET1=0X00790000; delay(); *IOCLR1=0X00790000; delay();
*IOSET1=0X00710000; delay(); *IOCLR1=0X00710000; delay();

}}

e) LCD interfacing
Include the header file <LPC21XX.H>. & <BOADR.H>.
Configure the Input Output Direction One register (IODIR 1) for selecting output port
operation of Port1 pins (P1.16 P1.23) to send the datas (D0-D7)
Configure the Input Output Direction Zero register (IODIR 0) for selecting output port
operation of Port0 pins (P0.28 P0.29) to select the Register bank Selection(RS) & Enable
signal to the LCD
Send the command words to the LCD through Input Output Set One register (IOSET1) and
give the appropriate control signals through IOSET0 Register
Call the delay program , while giving high to low enable signal
Send the data words to the LCD through Input Output Set One register (IOSET1) and give
the appropriate control signals through IOSET0 Register

12
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

f) UART PROGRAMMING
UART Transmitter
Include the <LPC214X.h> & <BOADR.H>.header file.
Configure the Port0 pin for UART0 TXD and RXD function for transmitting and receiving
the data.
Load the value 83 on the UART Zero Line Control Register (U0LCR) to frame the
message format.
Load the Device Latch LSB register (DLL) & Device Latch MSB register (DLM) register
to select the baud rate.
Load the value 0x03 on the UART Zero Line Control Register (U0LCR) to latch the baud
rate selection values.
load the data in to Transmit Holding Register (U0THR) for data transmission
UART Receiver
Include the <LPC214X.h> & <BOADR.H>.header file.
Configure the Port0 pin for UART0 TXD and RXD function for transmitting and receiving
the data. Load the value 83 on the UART Zero Line Control Register (U0LCR) to frame
the message format.
Load the Device Latch LSB register (DLL) & Device Latch MSB register (DLM) register
to select the baud rate. Load the value 0x03 on the UART Zero Line Control Register
(U0LCR) to latch the baud rate selection values.
Copy the received data from Receiver Buffer Register (U0RBR).
ADC INTERFACE
Include the < LPC214x.H> & <BOADR.H>.header file.
Load the value in ADCR (ADC control register) for the given specifications
[7:0] selection pin is used to select the ADC channel 1.
[15:8]select the clock divider value as 3
[16] Repeated data conversion
[19:17] select 000 for 11 clock 10 bits.
[21] Set to 1 to Analog to Digital converter is in operation mode .
[23:22] pin are used for device testing.
[24] Set to 1 to start the conversion (SOC).
[27] Set to 0 to indicate start of conversion on a falling edge.
Check the ADDR (ADC data register) [31] pin for End of conversion, when this register is
read and when the ADCR is return. If the ADCR is return, while a conversion still is
progress. This bit is set and a new conversion is started.
g) ADC Programming
#include<LPC21XX.H>
#include<BOARD.H>
int main()
{
unsigned int adcdata;
*PINSEL1= *PINSEL1 & 0XFCFFFFFF;
*PINSEL1= *PINSEL1 | 0X01000000;
*ADCR=0X01210302;
while(1)
{
if(*ADDR & 0X80000000)
{
adcdata=(*ADDR & 0X0000FFC0);
adcdata=adcdata>>6;
q_printf("%x\n",adcdata); }}}

13
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

e) LCD interfacing
#include<lpc21xx.h>
#include<BOARD.H>
void command(unsigned int comm);
void lcdout(unsigned int data);
void delay_lcd(void);
#define RS 0X20000000;
#define DIOW 0x10000000;
int main(void)
{
*IODIR1=0X00FF0000;
*IODIR0=0X30000000;
command(0x38); command(0x0c); command(0x01);

lcdout('E'); lcdout('C'); lcdout('E'); lcdout(' '); lcdout('S');


lcdout('E'); lcdout('C'); lcdout(' '); lcdout(' '); lcdout('E');
lcdout('S'); lcdout(' '); lcdout('L'); lcdout('A'); lcdout('B');
}
void delay()
{ unsigned int i;
for(i=0;i<5000 ;i++); return ;
}
void command(unsigned int comm)
{
*IOCLR1=0x00ff0000;
*IOCLR0=DIOW;
comm=comm<<16;
*IOSET1=comm; *IOCLR0=RS; delay(); *IOSET0=RS; delay();
return;
}
void lcdout(unsigned int data)
{ *IOCLR1=0x00ff0000;
*IOSET0=DIOW;
data = data << 16;
*IOSET1 = data; *IOSET0=RS; delay(); *IOCLR0=RS;
return; }

14
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

f) UART Transmitter
#include<LPC21xx.h>
#include<board.h>
int main(void)
{
char a[ ]="ECE";
int i;
*PINSEL0=0x01; /* Programming 0.0th Pin - Transmit data Pin */
*U0LCR=0x83; /* 8 -> Device lab = 1 , 3 -> 8 bit transmission*/
*U0DLM=0x00; /* Device latch MSB = 0 */
*U0DLL=0x18; /* Sets Baud rate */
*U0LCR=0x03;
while(1)
{
while(!(*U0LSR & 0x20));
for(i=0;a[i]!='\0';i++)
*U0THR= a[i]; }
return 0; }

Receiver
#include<LPC21xx.h>
#include<board.h>
void delay(void)
{
int j; for (j=0;j<50000;j++);
}
int main(void) {
unsigned int ALL;
*IODIR0=0x007f8000;
*PINSEL0 = 0x05; /* Programming 0.0th Pin - Transmit data Pin */
*U0LCR=0x83; /* 8 -> Device lab = 1 , 3 -> 8 bit transmission*/
/* Device latch MSB = 0 */
*U0DLL=0x61; /* Sets Baud rate */
*U0LCR=0x03;
while(1)
{
while (!(*U0LSR&0x01));
{
ALL=*U0RBR;
*IOSET0=ALL<<15;
delay();
*IOCLR0=ALL<<15;
delay();
}}}

RESULT

Thus the C language program was written and ported it on the ARM 7 core for the
following interfacing
Buzzer, LED, Relay, 7-segments LED, 2x16 LCD, ADC, and UART.

15
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

STATE DIAGRAM
RESET=1

S0

S1

S2

S3

S4

S5

S6
6

S7

RTL DIAGRAM

16
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

EXNO: DATE:

COUNTER IMPLEMENTATION USING FSM


AIM:
To write the Verilog code for a 3 bit counter using Finite State Machine behavior and
implement it on FPGA.

HARDWARE REQUIRED:

S.NO Name Type

1 FPGA Device
spartan3 architecture,
xc3s400 device
pq208 package
-4 speed grade

2 Xilinx 9.1 ISE

THEORY

Finite-state machine (FSM) or finite-state automaton (plural: automata), or simply a state


machine, is a behavioral model used to design computer programs. It is composed of a finite
number of states associated to transitions. A transition is a set of actions that starts from one state
and ends in another (or the same) state. A transition is started by a trigger, and a trigger can be an
event or a condition.

Finite-state machines can model a large number of problems, among which are electronic design
automation, communication protocol design, parsing and other engineering applications. In
biology and artificial intelligence research, state machines or hierarchies of state machines are
sometimes used to describe neurological systems

17
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

3 bit counter program


`define STATE0 3'b000
`define STATE1 3'b001
`define STATE2 3'b010
`define STATE3 3'b011
`define STATE4 3'b100
`define STATE5 3'b101
`define STATE6 3'b110
`define STATE7 3'b111
module counter(CLK,RESET, cnt);
input CLK,RESET;
output [2:0] cnt;
reg [2:0] next_cnt;
integer count;
assigncnt=next_cnt;
always @ (posedge CLK)
begin
if(RESET)
begin
count=0;
next_cnt=`STATE0;
end
else
begin
count=count+1;
if (count ==1000000)
begin
case (cnt)
`STATE0:begin
next_cnt=`STATE1;
count=0;
end
`STATE1:begin
next_cnt=`STATE2;
count=0;
end
`STATE2:begin
next_cnt=`STATE3;
count=0;
end
`STATE3:begin
next_cnt=`STATE4;
count=0;
end
`STATE4:begin
next_cnt=`STATE5;
count=0;
end
`STATE5:begin
next_cnt=`STATE6;

18
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

count=0;
end
`STATE6:begin
next_cnt=`STATE7;
count=0;
end
`STATE7:begin
next_cnt=`STATE0;
count=0;
end
default:next_cnt=`STATE0;
endcase
end
end
end
endmodule

Locked Pin constrains


NET "CLK" LOC = P79;
NET "RESET" LOC = P21;
NET "cnt<0>" LOC = P20;
NET "cnt<1>" LOC = P26;
NET "cnt<2>" LOC = P28;

RESULT:
Thus the FSM chart based 3 bit counter was verified and implemented successfully.

19
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

MULTIPLE OUTPUT PARALLEL LFSR ORDER 3 TRUTH TABLE

Present state 1,3 1,2 CLK

100 101 111 1

111 1 10 100 1

100 101 111 1

111 110 1

LFSR CODING

modulePPG(clk,reset,sin,sout);
inputclk;
input reset;
input [2:0]sin;
output[6:0] sout;
reg [2:0]a;
reg [2:0]b;
reg [2:0]c;
reg [2:0]d;
reg[6:0]temp;
always@(posedgeclk)
begin
if(reset)
temp=0;else
a[2:0]<=sin[2:0];
temp[0]=a[2]^a[0];
temp[1]=a[1]^a[0];
b[2]<=temp[0];
b[1]<=temp[1];
b[0]<=a[0];
temp[2]=b[2]^b[0];
temp[3]=b[1]^b[0];
c[0]<=b[0];
c[1]<=temp[3];
c[2]<=temp[2];
temp[4]=c[2]^c[0];
temp[5]=c[1]^c[0];
d[2]<=temp[4];
d[1]<=temp[5];
d[0]<=c[0];
temp[6]=d[2]^d[0];end
assign s out=temp;
endmodule
20
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

EXNO: DATE:

CRYPTO SYSEM IMPLEMENTATION USING ARM & FPGA

AIM

To implement multiple output parallel LFSR using Xilinx FPGA and verify the mono
alphabetic encryption & decryption algorithm using ARM 7 LPC 2148 microcontroller

TOOLS REQUIRED

SL.NO NAME TYPE

1 Triton IDE

2 Xilinx 9.1 ISE

HARDWARE REQUIRED

SL.NO NAME TYPE QUANTITY

1 LPC2148 Micro controller kit 1

2 FPGA Device 1
spartan3 Architecture,
xc3s400 Device number
pq208 Package
-4 Speed grade

3 DC Source (0-12)v 1

THEORY

LINEAR FEEDBACK SHIFT REGISTER

A LFSR is a shift-register where the output bit is an XOR function of some input bits. The
initial value of the LFSR is called the seed. The outputs that influence the inputs are called taps. A
LFSR is represented as a polynomial mod 2. The coefficients of the polynomial are either 1s or 0s.
For example, if the taps are at the 1st, 3rd bits, the polynomial is x3+ x+1. The structure shown is
n
called a serial architecture. If a polynomial is primitive, the corresponding LFSR can produce 2 -1
distinct patterns.

21
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

CRYPTO SYSTEM TRANSMITTER BLOCK DIAGRAM

RESET
MULTIPLE OUTPUT PARALLEL LFSR LOGIC DESIGN
CLOCK
Xilinx FPGA XC3S400
SIN [2:0]

SOUT [6:0]

LPC2148

BUFFER

BIT SHIFTER

MASKING UNIT

ENCRYPTING UART
MESSAGE
ALGORITHM TRANSMITTER TXD

22
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

PARALLEL LFSR

The parallel architecture of an LFSR reduces dynamic power consumption and can
generate more than one bit output per clock cycle. Here only one flip-flop is updated every clock
cycle and instead of the bits moving from left to right in each clock cycle, the taps of the XOR
tree move from right to left

The parallel architecture considers x3+ x+1 polynomial for obtaining multiple outputs in a
single clock cycle. The control signal Ti (i = 1, 2 ... N), which is used to connect the shift register
to the output tap, is a sequentially occurring waveform. The control signal is high for only i mod
N clock cycle, where N is the length of the LFSR The operations (1, 2) and (3, 1) are performed at
T1, where (x, y) denotes XOR operation of x and y. These values are stored in flip-flop 2 and flip-
flop 3 respectively. The overall operations can be summarized as shown in Table I. With the
multiple output architecture, a polynomial, of the form 1+xk1+xk2+xk3++xN7 can generate
outputs in a single clock cycle. In the case of x3+ x+1, 2 outputs can be obtained in a single clock

PRIMITIVE POLYNOMIAL

A primitive polynomial may refer to one of two concepts:

1 A polynomial over a unique factorization domain (such as the integers) whose greatest
common divisor of its coefficients is one.
2 The minimal polynomial of a primitive element of the extension field GF (pm).
MAXIMUM LENGTH SEQUENCE PROPERTIES:

When the PN sequence generated by linear feed back shift register has the length of 2 r-1, it is
called as maximum length sequence.

2 The length of the PN sequence generated by a primitive polynomial should be 2r-1. If the output
sequence satisfies this property, the polynomial is called as primitive. So the most secured
communication is achieved.

3. The number of ones is always one more than the number of zeros in each period of the
maximum length sequence whereas in truly randomsequence ones and zeros are equally
probable.Maximal length sequence:Tc , Tb=NTc

0 0 1 1 0 1 1

Maximal length sequences

23
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

CRYPTOSYSTEM RECEIVER BLOCK DIAGRAM

RESET
MULTIPLE OUTPUT PARALLEL LFSR LOGIC DESIGN
CLOCK
Xilinx FPGA XC3S400
SIN [2:0]

SOUT [6:0]

LPC2148

BUFFER

BIT SHIFTER

MASKING UNIT

UART
DECRYPTION
RXD RECEIVER MESSAGE
ALGORITHM

TO LEDS

24
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

RUN PROPERTY:

The m n means the sub sequence of identical symbols 1s or 0s.With in one period of the
sequence. The length of the run is equal to the length of the subsequence. When the maximum
length sequence is generated by linear feed back shift register of lengthr, total number of turns is
2r-1.In each period ofthe maximum length sequence there are one half runs of ones and zeros
having length 1.There can be one fourth runs of ones and zeros having length 2 or there can be
one eighth runs of ones and zeros having length 3 and so on.

CRYPTO SYSTEM

A cryptographically secure pseudo-random number generator (CSPRNG) is a pseudo-


random number generator (PRNG) with properties that make it suitable for use in cryptography.
Many aspects of cryptography require random numbers, for example:

Key generation
Nonces
Salts in certain signature schemes, including ECDSA, RSASSA-PSS.
One-time pads
The "quality" of the randomness required for these applications varies. For the generation of a
nonce, only uniqueness might be required. For the generation of a master key, a higher quality is
needed. And in the case of one-time pads, the information-theoretic guarantee of unbreakable
cryptography only holds if the random stream is obtained from a true random source.

CRYPTOSYSTEM TRANSMITTER

Most stream ciphers work by generating a pseudorandom stream of bits that are XORed
with the message; this stream can often be used as a good CSPRNG Here the PN sequence is
masked to generate the secured key then the message (01000100=0x41) is added with the masked
key sequence (00000011=0x03). So we can get the encrypted bits of (01000100=0x44). This
encrypted data is transmitted through UART module of LPC 2148 microcontroller.

CRYPTO SYSTEM RECEIVER

The receiver also performs the same XOR operation but here the encrypted received data
(01000100=0x44) called cipher text is subtracted with the masked key value (00000011=0x03).
Hence we can get the original message signal (01000100=0x41) which is nothing but the original
plain text.

25
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

ENCRYPTION ALGORITHM

Include the < LPC214x.H> header file


Configure the port0 pin of UART0 for transmitting the data
Configure the Input Output Direction zero register (IODIR0), to make the Output mode of
Port zero pins (P0.15 to P0.23)
Load the value 83 on the UART Zero Line Control Register (U0LCR) to frame the
message format.
Load the Device Latch LSB register (DLL) & Device Latch MSB register (DLM) register
to select the baud rate.
Load the value 0x03 on the UART Zero Line Control Register (U0LCR) to latch the baud
rate selection values.
Fetch the LFSR sequence from FPGA to LPC2148 Micro Controller

Perform right shift operation for two times


Based upon the key requirement Mask the shifted bits
Encrypt the message using Mono alphabetic encryption algorithm
View the encrypted data through UART transmitter or Terminal viewer
ENCRYPTION PROGRAM:

#include<lpc21xx.h>
#include<BOARD.h>
void delay()
{unsigned int i;
for(i=0;i<=20000;i++);
}
int main(void)
{
unsigned int j,k,rt,t;
*IODIR0=0x007f8000;
*PINSEL0=0x01;/*programming0.0th pin- transmit data pin*/
*U0LCR=0x83;/*8->Device lab=1,3->8 bit transmission*/
*U0DLM=0x00;/*Device latch MSB=0*/
*U0DLL=0x18;/*Set baud rate*/
*U0LCR=0x03;
while (1)
{
j=*IOPIN0;
k=((j& 0x000003fc)>>2);
//delay();
rt=(k&0x0000000f);
while(!(*U0LSR&0x20));
//for(i=0;a[i]!=\0;i++)
{
t=(0x41+rt);
*U0THR=t;
*IOSET0=t<<15;
delay();
delay();
*IOCLR0=t<<15;
}}
return 0; }
26
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

DECRYPTION ALGORITHM

Include the < LPC214x.H> header file


Configure the port0 pin of UART0 for receiving the data
Load the value 83 on the UART Zero Line Control Register (U0LCR) to frame the
message format. Load the Device Latch LSB register (DLL) & Device Latch MSB register
(DLM) register to select the baud rate. Load the value 0x03 on the UART Zero Line
Control Register (U0LCR) to latch the baud rate selection values.
Fetch the LFSR sequence from FPGA to LPC2148 Microcontroller
Perform right shift operation for two times
Based upon the key requirement Mask the shifted bits
Decrypt the message using Mono alphabetic decryption algorithm
View the decrypted message through LED
DECRYPTION PROGRAM:
#include<lpc21xx.h>
#include<BOARD.h>
void delay (void);
void delay()
{
unsigned int i;
for(i=0;i<=20000;i++);
}
int main(void)
{
unsigned int j,k,rt,r,t,ALL;
*IODIR0=0x007f8000;
*PINSEL0=0x05;
*U0LCR=0x83;
*U0DLL=0x18;
*U0LCR=0x03;
while(1)
{
j=*IOPIN0;
delay();
while(!(*U0LSR&0x01));
{
k=(j&0x000007fc)>>2;
rt=(k&0x0000000f);
ALL=*U0RBR;
r=ALL-rt;
*IOSET0=r<<15;
delay( );
*IOCLR0=r<<15;
}}
return 0;
}
RESULT
Thus the multiple output parallel LFSR logic was implemented using Xilinx FPGA and the
mono alphabetic encryption and decryption algorithm was verified with LPC 2148
Microcontroller.
27
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

4X4 MARTIX KEYPAD

28
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

EXNO: DATE:
SPEED CONTROL OF STEPPER MOTOR
AIM
To develop an application to control the Stepper motor speed using LPC 2148
microcontroller.

TOOLS REQUIRED:

S.NO Name Type

1 Triton IDE

2 Flash Fusion Fusing software

HARDWARE REQUIRED:

S.NO Name Type Quantity

1 ARM 7 LPC 2148 Microcontroller kit 1

2 DC source (0-12)V 1

ALGORITHM:

Include the header file <LPC21XX.H>.


Include the header file <BOADR.H>.
Configure the Port 0 pins (P0.0 & P0.1) as UART0 operation using Pin Selection Zero
Register (PINSEL0).
Configure the Input Output Direction One register (IODIR 1) for selecting output operation of
Port1 pins (P1.16 P1.23) for 7 segment interface.
Configure the Input Output Direction Zero register (IODIR 0) for selecting output and input
port operation of Port0 pins (P0.2 P0.9) for 4x4 matrix keypad interface.
Load the value 83 on the UART Zero Line Control Register (U0LCR) to frame the message
format.
Load the Device Latch LSB register (DLL) & Device Latch MSB register (DLM) register to
select the baud rate.
Load the value 0x03 on the UART Zero Line Control Register (U0LCR) to latch the baud rate
selection values.
By using 4x4 matrix keypad select the various speed levels. This activates the motor control
signals respectively

STEPPER MOTOR SPEED CONTROL PROGRAM


#include<lpc21xx.h>
#include<board.h>
void delay()
{
unsigned int i;
for(i=0;i<=10000;i++);
}
void delay1()
{
unsigned int i;
29
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

for(i=0;i<=20000;i++);
}
int sendchar0(int ch)
{
while(!(*U0LSR&0x20));
return(*U0THR=ch);
}
int main()
{
unsigned int l;
//*VICVectCntl0=0x20 |6;
*PINSEL0=0x00000005;
*U0LCR=0x83; /* 8 -> Device lab = 1 , 3 -> 8 bit transmission*/
*U0DLM=0x00; /* Device latch MSB = 0 */
*U0DLL=0x18; /* Sets Baud rate */
*U0LCR=0x03;
//*U0IER=0X02;
*PINSEL2= *PINSEL2 & 0xFFFFFFF3;
*IODIR1 = 0X01fF0000;
*IODIR0=0x007f83fc;
*IOCLR0=0x007f8000;
{
while(1)
{
*IOCLR0=0x00000DFF;
*IOSET0=0x00000200;

if((*IOPIN0 & 0x0000003C)== 0x00000004)


{
sendchar0 ('C');
*IOSET1 = 0x390000; //Display C
*IOSET0=0x00006000;
delay();
*IOCLR0=0x00006000;
*IOSET0=0x0000A000;
delay();
*IOCLR0=0x0000A000;
*IOSET0=0x00009000;
delay();
*IOCLR0=0x00009000;
*IOSET0=0x00005000;
delay();
*IOCLR0=0x00005000;
*IOCLR1 = 0xff0000;
}
else if((*IOPIN0&0x0000003C)==0x00000008)
{
sendchar0('8');
*IOSET1 = 0x7f0000;
*IOSET0=0x00006000;
delay();delay();
*IOCLR0=0x00006000;

30
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

*IOSET0=0x0000A000;
delay();delay();
*IOCLR0=0x0000A000;
*IOSET0=0x00009000;
delay();delay();
*IOCLR0=0x00009000;
*IOSET0=0x00005000;
delay();delay();
*IOCLR0=0x00005000;
*IOCLR1 = 0Xff0000;
}
else if((*IOPIN0&0x0000003C)==0x00000010)
{
sendchar0('4');
*IOSET1 = 0x660000; //Display 4
*IOSET0=0x00006000;
delay();delay();delay();
*IOCLR0=0x00006000;
*IOSET0=0x0000A000;
delay();delay();delay();
*IOCLR0=0x0000A000;
*IOSET0=0x00009000;
delay();delay();delay();
*IOCLR0=0x00009000;
*IOSET0=0x00005000;
delay();delay();delay();
*IOCLR0=0x00005000;
*IOCLR1 = 0Xff0000;
}
else if((*IOPIN0&0x0000003C)==0x00000020)
{
sendchar0('0');
*IOSET1 = 0x3F0000; //Display 0
*IOSET0=0x00006000;
delay();delay();delay();delay();
*IOCLR0=0x00006000;
*IOSET0=0x0000A000;
delay();delay();delay();delay();
*IOCLR0=0x0000A000;
*IOSET0=0x00009000;
delay();delay();delay();delay();
*IOCLR0=0x00009000;
*IOSET0=0x00005000;
delay();delay();delay();delay();
*IOCLR0=0x00005000;
*IOCLR1 = 0Xff0000;
}

*IOCLR0=0x00000EFF;
*IOSET0=0x00000100;
if((*IOPIN0&0x0000003C)==0x00000004)
{

31
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

sendchar0('D');
*IOSET1 = 0x5E0000;
delay1(); //Display D
*IOCLR0=0x0ff0000;
}
else if((*IOPIN0&0x0000003C)==0x00000008)
{
sendchar0('9');
*IOSET1 = 0x6f0000; //Display 9
delay1();
*IOCLR1 = 0Xff0000;
}
else if((*IOPIN0&0x0000003C)==0x00000010)
{
sendchar0('5');
*IOSET1 = 0x6d0000; //Display 5
delay1();
*IOCLR1 = 0Xff0000;
}
else if((*IOPIN0&0x0000003C)==0x00000020)
{
sendchar0('1');
*IOSET1 = 0x060000; //Display 1
delay1();
*IOCLR1 = 0Xff0000;
}
*IOCLR0=0x00000F7F;
*IOSET0=0x00000080;
if((*IOPIN0& 0x0000003C)==0x00000004)
{
sendchar0('E');
*IOSET1 = 0x790000; //Display E
delay1();
*IOCLR1 = 0xff0000;
}
else if((*IOPIN0&0x0000003C)==0x00000008)
{
sendchar0('A');
*IOSET1 = 0x770000; //Display A
delay();
*IOCLR1 = 0xff0000; }
else if((*IOPIN0&0x0000003C)==0x00000010)
{ sendchar0('6');
*IOSET1 = 0x7d0000; //Display 6
delay();
*IOCLR1 = 0Xff0000;
}

else if((*IOPIN0&0x0000003C)==0x00000020)
{
sendchar0('2');
*IOSET1 = 0x5b0000; //Display 2

32
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

delay();
*IOCLR1 = 0Xff0000;
}

*IOCLR0=0x00800FBF;
*IOSET0=0x00000040;
if((*IOPIN0&0x0000003C)==0x00000004)
{
sendchar0('F');
*IOSET1 = 0x710000; //Display F
delay();
*IOCLR1 = 0xff0000;
}
else if((*IOPIN0&0x0000003C) == 0x00000008)
{
sendchar0('B');
*IOSET1 = 0x7c0000; //Display B
delay();
*IOCLR1 = 0xff0000;
}
else if((*IOPIN0&0x0000003C)==0x00000010)
{
sendchar0('7');
*IOSET1 = 0x070000; //Display 7
delay();
*IOCLR1 = 0Xff0000;
}
else if((*IOPIN0&0x0000003C)==0x00000020)
{
sendchar0('3');
*IOSET1 = 0x4f0000;
delay();
*IOCLR1 = 0Xff0000;
}}}}

RESULT
Thus the Stepper motor speed was controlled by using ARM 7 - LPC 2148 RISC
microcontroller.

33
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

SWITCH INTERFACING
#include<LPC21xx.H>
int main()
{
IODIR1=0X00FF0000;
while(1)
{
IOCLR1=0x00FF0000;
IOSET1= ((IOPIN0&0X0000FF00)<<0X08);
} }
STEPPER MOTOR INTERFACING:
#include<LPC21xx.H>
void delay()
{
unsigned int i;
for(i=0;i<=10000;i++);
}
int main()
{
IODIR0=0X000000FF;
for(;;)
{
IOSET0=0X00000051; delay(); IOCLR0=0x00000051;
IOSET0= 0x00000062; delay(); IOCLR0=0x00000062;
IOSET0= 0x00000094; delay(); IOCLR0=0x00000094;
IOSET0= 0x000000A8; delay(); IOCLR0=0x000000A8;
} }

SWITCH SAMPLE OUTPUT

34
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

APPENDIX A
EX NO: DATE:
VERIFICATION AND VALIDATION USING Keil IDE
AIM
To verify and validate the given applications using industry standard Integrated Development
Environment Keil vision ARM-MDK.
Rolling LED Display, Stepper motor, Switch interfacing.

TOOLS REQUIRED:

S.NO Name Type

1 Keil vision4 IDE

2 ARM 7-LPC 2148 Microcontroller

ALGORITHM:
STEPPER MOTOR INTERFACING:

Include the < LPC214x.H> header file


Configure the Port0 pins (P0.0to P0.7) as GPI0 using Pin Selection Zero Register (PINSEL0).
Configure the Input Output Direction zero register (IODIR 0), to make the Input mode of Port zero
pins (P0.0 to P0.3)
Configure the Input Output Direction zero register (IODIR 0), to make the Output mode of Port
zero pins (P0.4 to P0.7)
Based on the stepper motor winding sequence, make the corresponding port pins to active high
through Input Output Pin zero Register (IOPIN 0)
Call the delay program

SWITCH INTERFACING
Include the < LPC214X.H> header file
Configure the Port 0 pins (P0.16 to P0.23) as GPI0 using Pin Selection one Register (PINSEL1).
Configure the Input Output Direction zero register (IODIR 0) for selecting input and output
operation of Port0 pins (P0.16 to P0.23) as per hardware pins schematic.
Based on the IO interfacing, make the corresponding port pins to active high through Input Output
Set zero Register (IOSET0) register.
Call the delay program
To reset the output port pin, make corresponding port pin to active high through Input Output Clear
Zero Register ( IOCLR0)
PROCEDURE:

Click on the D (debug icon) to start the debugger simulator program.


Based on the application, place the necessary peripheral on the simulator window.
To verify the execution, apply the appropriate inputs through port pins and then validate the results.

35
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

LED DISPLAY

#include<LPC21xx.H>
void delay()
{
unsigned int i;
for(i=0;i<=10000;i++);
}
int main()
{
IODIR0=0X000000FF;
for(;;)
{
IOSET0=0X000000FF; delay();
IOCLR0=0x000000FF;
} }

36
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

RESULT:
Thus the switch, stepper motor interfacing programs were verified and validated successfully.

37
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

APPENDIX B

MULTITASKING PROGRAM
#include <LPC21xx.H> /* LPC21xx definitions */
#include <ucos.h>
#include <board.h>
#define TASK_STK_SIZE 100 /* Size of each task's stacks (# of WORDs) */
#define NO_TASKS 3 /* Number of identical tasks */
char TaskData[NO_TASKS];
OS_STK TaskStk[NO_TASKS][TASK_STK_SIZE]; /* Tasks stacks */
OS_STK TaskStartStk[TASK_STK_SIZE];
extern void init_timer (void);
void Task2 (void *data)
{
int n, i;
data = data; // avoid compiler warning
while(1)
{
for (n = 0x00080000; n <= 0x04000000; n <<= 1)
{
*IOSET0 = n; /* Blink LED 5, 6 ,7 ,8*/ /* Turn on LED */
OSTimeDly(10); /* Wait one second */
*IOCLR0 = n; /* Turn off LEDs */
OSTimeDly(10); /* Wait one second */
i++;
q_printf("LoPrio "); } } }
void Task1 (void *data)
{ int n, i;
data = data; // avoid compiler warning
while(1)
{
for (n = 0x00008000; n <= 0x00040000; n <<= 1)
{
*IOSET0 = n; /* Blink LED 1,2, 3, 4 */
q_printf("Task1 LEDON ");
OSTimeDly(10); /* Wait one second */
q_printf("Task1 LEDOFF ");
*IOCLR0 = n; /* Turn off LEDs */
OSTimeDly(10); /* Wait one second */
q_printf("%s", "HiPrioTsk ");
i++;
} } }
void startTask(void *data)
{
init_timer();
TaskCreate(Task1, (void *)&TaskData[0], "HiPrioTsk", 1);
TaskCreate(Task2, (void *)&TaskData[1], "LoPrioTsk", 2);
while (1)
{ OSTimeDly(1000); }}
int main (void)
{
*IODIR0 = 0x007F8000;
OSInit(); /* Initialize uC/OS-II */
init_timer();
TaskCreate(startTask, (void *)0, "VHiPrioTsk", 0);
OSStart(); /* Start multitasking */
return 0; // Actually we should never come here }

38
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

EX NO: DATE:

VERIFICATION AND VALIDATION USING RTOS


AIM
To verify and validate the given applications using industry standard open source IDE. 1)
Multitasking 2) Message queues.

TOOLS REQUIRED:

S.NO Name Type

1 Triton IDE

2 Flash Fusion Fusing software

HARDWARE REQUIRED:

S.NO Name Type Quantity

1 ARM 7 - LPC 2148 Microcontroller kit 1

2 DC source (0-12)V 1

ALGORITHM

MULTITASKING
Include the header file LPC21xx.h , Board.h and ucos.h
Define the Stack size and number of tasks
Initialize the Task Stack size and number of task
Call the Timer function initialization
With in the main function, initialize the C-OS-II kernel
Call the Timer function initialization
Crate the Start Up Task
To start the multitasking call the function OSStart.
Terminate the main program
With in the startup creation, initialize the timer function call and create the remaining tasks named
as task1 and task1
Give the time delay for the task
With in the task 1 and task 2 write the LED control operation code with time delay

39
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

MESSAGE QUEUE PROGRAM


#include <LPC21xx.H> /* LPC21xx definitions */
#include <ucos.h>
#define TASK_STK_SIZE 100 /* Size of each task's stacks (# of WORDs) */
#define NO_TASKS 5 /* Number of identical tasks */
OS_STK TaskStk[NO_TASKS][TASK_STK_SIZE]; /* Tasks stacks */
OS_STK TaskStartStk[TASK_STK_SIZE];
char TaskData[NO_TASKS]; /* Parameters to pass to each task */
OS_EVENT *MQue; /* Message Queue pointer */
void *MQueTable[20]; /* array to store Messages */
extern void init_timer (void);
void Task2 (void *data)
{
char tx1msg[] = "Hello T1\n";
char tx2msg[] = "This is msg from T2\n";
data = data; /* Prevent compiler warning */
while(1)
{
q_printf("Task2 \n");
OSQPost(MQue, (void *)&tx1msg); /* Send message to MQ */
OSQPost(MQue, (void *)&tx2msg);
OSTimeDly(100); }
q_printf("Task should not have come here"); }
void Task1 (void *data)
{ U8 err;
char *rxmsg;
data = data; /* Prevent compiler warning */
q_printf("Task1 \n");
while(1)
{
rxmsg = (char *)OSQPend(MQue, 0, &err); /* Wait for message in MQ */
q_printf(rxmsg);
}
q_printf("Task should not have come here");}
void TaskStart (void *data)
{
data = data; /* Prevent compiler warning */
init_timer();
MQue = (OS_EVENT *) OSQCreate(&MQueTable,20); q_printf("uC/OS-II, The Real-
Time Kernel ARM Ported version\n");
TaskCreate(Task1, (void *)&TaskData[1], "Task1", 3);
TaskCreate(Task2, (void *)&TaskData[2], "Task2", 2);
while(1)
{
OSTimeDly(1500); /* Wait one second */ }}
int main (void)
{
OSInit(); /* Initialize uC/OS-II */
init_timer();
TaskCreate(TaskStart, (void *)0, "Task Start", 0);
OSStart(); /* Start multitasking */

40
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

return 0; // Actually we should never come here }


MESSAGE QUEUE
Include the header file LPC21xx.h , Board.h and ucos.h
Define the Stack size and number of tasks
Initialize the Task Stack size and number of task
Create OS mailbox Event
Initialize array value to store the message
Call the Timer function initialization
With in the main function, initialize the C-OS-II kernel
Call the Timer function initialization
Crate the Start Up Task
To start the multitasking call the function OSStart.
Terminate the main program With in the startup creation, initialize the timer function call and
create the remaining tasks named as task1 and task1
Create the message queue function
Give the time delay for the task
With in the task 1, initialize the pointer for transmit message
Through this pointer variable, Post the datas to mailbox
With in the task 2, initialize the pointer for receiving the message
Through this pointer variable, Pend the datas from the ,mailbox

RESULT:
Thus the multitasking and message queue programs were verified and validated successfully.

41
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

APPENDIX C

PROCEDURE FOR TRITON IDE


1) To create a new project PROJECT-> NEW-> C Project ->This will open new project

2) Enter the new project name and configure the remaining settings

42
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

3) Select debug, Release , Show all project types and show all configurations then give Next

4) This will open a new Project workspace. There you open the C file and type program. In case of
RTOS, select the OS as MCOS-II

43
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

5) Right Click on the project folder to Select the Build mode in Active build configurations, Build and
Rebuild operations

44
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

1) After performing the above operation hex file will be created under the release folder. To download
the hex file , open Release folder and right click on the hex file then select download .
Make sure that, controller kit must be in ISP mode for programming

45
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

APPENDIX D:
Selected Function
Binary Value
00 First alternate function Primary (default) function (always GPIO)
01 Second Alternate function
10 Third Alternate function
11fourth alternate function
PINSEL0 Register Lower order two bytes

PINSEL0 Register higher order bytes

46
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

PINSEL2 Register

47
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

PINSEL1 Register Lower order bytes

UART0 Line Control Register Bit Description:


U0 Function Description Reset
LCR Value
Word Length 00: 5 bit character length
1:0 01: 6 bit character length
Select 0
10: 7 bit character length
11: 8 bit character length
2 Stop Bit Select 0: 1 stop bit
0
1: 2 stop bits (1.5 if U0LCR[1:0]=00)
0: Framing error status is inactive.
Framing
3 1: Framing error status is active. 0
Error (FE)
00: Odd parity
01: Even parity
5:4 Parity Select 0
10: Forced 1 stick parity
11: Forced 0 stick parity
0: Disable break transmission
1: Enable break transmission.
6 Break Control 0
Output pin UART0 TxD is forced to logic 0 when
U0LCR is active high.
Divisor Latch 0: Disable access to Divisor Latches
7 0
Access Bit 1: Enable access to Divisor Latches

48
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

UART0 Line Status Register Bit Description:


U0LSR Function Description Reset
Value
Receiver 0: U0RBR is empty
0 Data Ready 1: U0RBR contains valid data
(RDR) U0LSR0 is set when the U0RBR holds an unread 0
character and is cleared when the UART0 RBR
FIFO is empty.
Overrun 0: Overrun error status is inactive.
1 Error 1: Overrun error status is active.
0
(OE)

0: Parity error status is inactive.


Parity Error
2 1: Parity error status is active. 0
(PE)
Framing 0: Framing error status is inactive.
3 Error 1: Framing error status is active. 0
(FE)
Break 0: Break interrupt status is inactive.
4 Interrupt 1: Break interrupt status is active. 0
(BI)
Transmitter 0: U0THR contains valid data.
Holding 1: U0THR is empty.
5 Register THRE is set immediately upon detection of an 1
Empty empty UART0 THR and is cleared on a U0THR
(THRE) write.
0: U0THR and/or the U0TSR contains valid data.
Transmitter 1: U0THR and the U0TSR are empty.
6 Empty TEMT is set when both U0THR and U0TSR are 1
(TEMT) empty; TEMT is cleared when either the U0TSR or
the U0THR contain valid data.
0: U0RBR contains no UART0 Rx errors or
Error in Rx U0FCR0=0.
7 FIFO 1: UART0 RBR contains at least one UART0 Rx 0
(RXFE) error.

Baud Rate Calculation:

Clock frequency / (16 * baud rate) = decimal Hex DLM & DLL

49
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

ADCR A/D CONTROL REGISTER


Reset
ADCR Function Description
Value
Reserved, user software should not write ones to reserved bits. The
23:22 NA
value read from areserved bit is not defined.
000
When the BURST bit is 0, these bits control whether and when an
A/D conversion is
started:
No start (this value should be used when clearing PDN to 0).
001 Start conversion now.
010 Start conversion when the edge selected by bit 27 occurs on
P0.16/EINT0/MAT0.2/CAP0.2 pin.
START 011 Start conversion when the edge selected by bit 27 occurs on
26:24 0
P0.22/CAP0.0/MAT0.0 pin.
100 Start conversion when the edge selected by bit 27 occurs on
MAT0.1.
101 Start conversion when the edge selected by bit 27 occurs on
MAT0.3.
110 Start conversion when the edge selected by bit 27 occurs on
MAT1.0.
111 Start conversion when the edge selected by bit 27 occurs on
MAT1.1.
1- This bit is significant only when the START field contains 010-
111. In these cases:
EDGE Start conversion on a falling edge on the selected CAP/MAT signal.
27 0
0 Start conversion on a rising edge on the selected CAP/MAT
signal.

user software should not write ones to reserved bits. The value read
31:28 from a NA
Reserved,
- reserved bit is not defined.

50
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

APPENDIX E

HOW TO CREATE PROJECT USING ECLIPSE IDE


Step 1: Goto File -> New -> C Project. Enter the project name. Make sure the selections are
as shown in Figure. Click Next.!

Step 2: Select Debug and Release as shown in Figure. Then, press Finish.

51
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

Step 3: Go to File -> Import -> General -> File System.

Step 4: Press Next. Browse and select the project from Softwares_Stellaris . Press Finish.
Or
Create the source files namely main.c, startup_gcc.c, main.ld and readme.text by clicking
FILE-> NEW-> SOURCE FILE.

52
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

Your screen should look similar to it!

Step 5: Go to Project Properties. Under C\C++ build -> settings -> Tool Settings -> target
processor -> choose cortex M3.
Step 6: ARM Sourcery Windows GCC C Compiler -> preprocessor -> add source -> type
gcc and give ok.

53
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

Step 7: Go to Project Properties. Under Settings -> Tool Settings -> ARM Sourcery
Windows GCC C Compiler -> Directories.

Step 8: Include all directory paths as shown in Figure.

54
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

Step 9: Setting up code optimization.

Step 10: Including the linker. In the Project Properties window, go to Tool Setting -> ARM
Sourcery Windows GCC C Linker -> General.

55
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

Step 11: Add the libraries. In the Project Properties window go to Tool Setting -> ARM
Sourcery Windows GCC C Linker ->Libraries.

Add the two directory paths as shown in Figure.

56
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

Step 12: In the Project Properties window, go to C/C++ General -> Paths and Symbols ->
Source Location -> Link Folder.

Step 13: Include the driverlib and utils folder, which contain the C source files.

57
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

Your screen should look similar to it!

Step 14 : In the Project Properties window, go to C/C++! Build -> Settings ->
Build Steps -> Post Build Steps Command and type the following.

arm-none-eabi-objcopy -S -O binary "${ProjName}.elf "${ProjName}.bin

58
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

Step 15: Right click on the project opened in the workspace, go to Build Configurations and
build and clean the project.

Step 16: Go to Run -> External Tools -> External Tools Configuration

59
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

Step 17: In the window, set the location to LMFlash.exe located under C:/Program
Files/Texas Instruments/ and click run.

Step 18: After clicking Run, a window similar to below should display on the screen. In the
configuration tab, choose the COM port depending on the port the device is attached to.

60
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

Step 19: Go to the Program tab, and select the .bin file by browsing to your project in the
Eclipse workspace folder. Make sure the address offset is 0800.

Step 20: Clicking on Program starts transferring the application binary file to the Stellaris
Guru board.

61
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

Circuit Diagram:

Switches and LEDs- circuit diagram

Fig. switch

Fig. LED

62
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

VIVA QUESTIONS

VERIFICATIONAND VALIDATION USING Eclipse IDE


1) What are the features of cortex LM3S608?
ARM Cortex -M3 v7-M Processor Core
Upto 80 MHz, Upto 100MIPS (at80MHz)
On-ChipMemory 256KB Flash, 96KBSRAM.
ROM Loaded with Stellaris Driver Lib Boot loader, AES Tables and CRC.
External Peripheral Interface (EPI)
32 bit dedicated parallel bus for external peripherals.
Supports SDRAM, SRAM/Flash, M2M.
Advanced Serial Integration
10/100 Ethernet MAC and PHY
CAN 2.0 A/B Controllers.
USB Full Speed, OTG/Host/Device.
UARTs with IrDA and ISO 7816 support.
2 I2Cs, 2 Synchronous Serial Interfaces (SSI), Integrated Inter chip Sound
(I2S).
System Integration
32 Channel DMA Controllers. Internal precision 16MHz oscillator, 2
watchdog times with separate clock domains.
ARM Cortex SysTick timer.
4x32 bit timers with RTC capability.
Lower power battery backed hibernation module.
Flexible pin muxing capability.
Advanced Motion Control
8 advanced PWM outputs for motion and energy applications.
2 Quadrature Encoder Inputs (QEI).
Analog
2 x8Channel 10 bit ADC (for a total of 16 channels).
3 analog comparators.
On chip voltage regulator (1.2V internal operation).

2) What are the advantages of open source product over licensed product?
Low cost and no license fees.
Open standards that facilitate integration with other Systems.
It is easily customizable.

3) What is Eclipse IDE?


Eclipse is a multi-language software development environment comprising an
integrated development environment (IDE) and an extensible plug-in system. It is written
mostly in Java. It can be used to develop applications in Java and, by means of various
plug-ins, other programming languages including Ada, C, C++, COBOL, etc.

63
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

4) What is code sourcery?

CodeSourcery develops Sourcery G++, an Eclipse based Integrated Development


Environment (IDE) that incorporates the GNU Toolchain (gcc, gdb, etc.) for cross
development for numerous target architectures. CodeSourcery provides a "lite" version for
ARM, Coldfire, MIPS, SuperH and Power architectures. The toolchains are always very up to
date. CodeSourcery contributes enhancements it makes to the GNU Toolchain upstream
continually, making it the single largest (by patch count) corporate contributor.
5) Difference between debug mode and release mode?


In debug mode, many of the compiler optimizations are turned off which allow the
generated executable match up with the code. This allows breakpoints to be set
accurately and allows a programmer to step through the code one line at a time.
Debugging information is also generated help the debugger figure out where it is in
the source code.
In release mode, most of the compiler's optimizations are turned on. Chunks of
your code could be completely deleted, removed, or rewritten. The resulting
executable will most likely not match up with your written code. However,
normally release mode will run faster then debug mode due to the optimizations.
6) What is the need for header files?

A header file is a file containing C declarations and macro definitions to be shared


between several source files. The use of a header files in our program by including it, with the
C preprocessing directive `#include'.
Header files serve two purposes.

System header files declare the interfaces to parts of the operating system. It should be
included in our program to supply the definitions and declarations that need to invoke
system calls and libraries.
Header files contain declarations for interfaces between the source files of our program.
Each time a group of related declarations and macro definitions all or most of which are
needed in several different source files, it is a good idea to create a header file for them.
7) What is the need for driver library?
The Driver Library includes drivers for all classes of Stellaris microcontrollers.
This directory contains the source code for the drivers.
8) What is the need for inc file?
This directory holds the part specific header files used for the direct register access
programming model.
9) What is the use of GNU MAKE?
It converts .elf file to .bin file.
10) What are the different header files used in our program and mention it uses?
Header files, one per peripheral that describe all the registers and the bit fields within
those registers for each peripheral. These header files are used by the drivers to directly
access a peripheral, and can be used by application code to bypass the peripheral driver
library API.

64
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

#include "inc/hw_memmap.h"- defines the base address of the memories and


peripherals.
#include "inc/hw_types.h"- defines the common types and macros.
#include "driverlib/gpio.h" - defines macros for GPIO API.
#include "driverlib/sysctl.h" - defines the prototypes for the system control driver.
#include "utils/uartstdio.h" - defines the utility driver to provide simple UART
console functions.
#include "driverlib/uart.h" - defines the Macros for UART API.
11) What is the use of SysCtlClockSet function?
It sets the clocking of the device. This function configures the clocking of the
device. The input crystal frequency, oscillator to be used, use of the PLL, and the system
clock divider are all configured with this function.
12) What is the use of SysCtlPeripheralEnable function?
This function enables peripherals. At power-up, all peripherals are disabled; they
must be enabled in order to operate or respond to register reads/writes.
13) What is the use of GPIOPinTypeGPIOOutput function?
It Configures pin(s) for use as GPIO outputs. The pin(s) are specified using a bit-
packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of
the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on.
14) What is the use of GPIOPinWrite function?
It writes a value to the specified pin(s).
15) What are the parameters present in UARTConfigSetExpClk function?
ulBase is the base address of the UART port.
ulUARTClk is the rate of the clock supplied to the UART module.
ulBaud is the desired baud rate.
ulConfig is the data format for the port (number of data bits, number of stop bits, and
parity).
16) What will UARTCharPut and UARTCharGet functions do?
UARTCharGet (It waits for a character from the specified port)-This function
gets a character from the receive FIFO for the specified port. If there are no characters
available, this function waits until a character is received before returning.
UARTCharPut (It waits to send a character from the specified port)- This
function sends the character ucData to the transmit FIFO for the specified port. If there is
no space available in the transmit FIFO, this function waits until there is space available
before returning.
17) What will SysCtlDelay function do?
It provides a small delay. It utilizes the system control register for making delay.
The system control block has 24 bit register to provide time delay.

65
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

HIGH LEVEL LANGUAGE PROGRAMMING AND PORTING USING LPC 2148


1. What do you meant by verification and validation?
The verification process is performed after developing hardware, software and
integrating both. The main aim of this process is to verify the developed or designed
module, whether meets the specified objective or not. If the result goes wrong, the
designer has to do the redesign. If the results are satisfied we can go for validation. The
validation process is used to analyze the performance of the system.
2. What is ARM 7 TDMI?
Advanced RISC Machine core 7, which supports Thumb instruction, Debugger support,
enhanced Multiplier, In circuit emulator.
3. What do you meant by interfacing?
Interfacing is the process of making communication between master and the
peripheral device. The communication may be hardware or software level.
4. What is the use of IOSET and IOCLR (clear) register?
IOSET register is used send the logic 1 on the particular port pin.
IOCLR register is used to make the logic 0 on the port pin.
In order to change the port pin status from high to low, IOCLR to be used
5. What is the use of IODIR (direction) register?
IO Direction register is used to set the direction path of a port pin that is either input or
output.
6. What are various types of switches?
Toggle switches, Push Button switches, SPST, SPDT
7. What are the various types of output devices?
LED, 7 segment LED, LCD, Motors
8. What is the need for delay program?
In order to communicate properly between the IO device and master
(microprocessor) speed of operation of the devices to be matched. Delay programs are
used to match the speed.
9. Why the PIN SELECTION registers must be configured?
The port pins are multiplexed in nature that is, a single port pin can perform 4
different operations. In order to select the particular feature the PIN Selection must be
configured. By default all the pins are configured as general purpose IO pin.
10. What is the necessity to use infinite loop?
Master executes the codes written on this loop continuously. If you want to execute the
code for a time, you can use it below the main function.
11. What is the need for delay program?
In order to communicate properly between the IO device and master (microprocessor)
speed of operation of the devices to be matched. Delay programs are used to match the
speed.
12. What is the necessity to use infinite loop?
Master executes the codes written on this loop continuously. If you want to execute the
code for a time, you can use it below the main function.
13. What will be the effect if you not include the .h file?
The compiler cant convert the appropriate machine code for the target processor.
The supporting datas cannot be taken.
14. What are various integer initialization types?
66
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

unsigned int -32 bit


signed int - 31 bit for a 32 bit microcontroller
15. How do you convert the datas from working host system to target system?
The Hexa decimal file is created by the IDE in the project name. the hex file is
downloaded to the memories of the target processor.
VERIFICATIONAND VALIDATION USING RTOS COS-II
1.What do you meant by multitasking?
Multi-tasking is the ability to execute more than one task at the same time.
2.What do you meant by RTOS?
RTOS stands for Real time Operating system. Not only the logical correctness of the
computation and the time at which the result is produced. In RTOS a late answer is a
wrong answer.
3.What are the features of RTOS?
Multi-Tasking, communication between tasks like semaphore management, mailboxes,
queues, time delays
4.Differentiate between application task and startup task.
The start-up task is executed by the OS Application tasks are executed from the
first startup task itself
OS initialization done at here only Initialization of OS cant be performed
Application tasks are created from here Creation of task is not possible but
only another task can be invoked
Timing dead line can be given Timing dead line can be given
5.Name few RTOS based embedded application.
Mobile phone, network router, missile systems, satellites, ATM etc
6. What will be the effect if you not include the .h file?
The compiler cant convert the appropriate machine code for the target processor.
The supporting datas cannot be taken.
7. What are various integer initialization types?
unsigned int -32 bit
signed int - 31 bit for a 32 bit microcontroller
8. What are the software used to build the embedded system?
Triton IDE / keil IDE - Integrated Development Environment
Flash Fusion fusing software
Xilinx ISE- Integrated Software Environment
9. How do you convert the datas from working host system to target system?
The Hexa decimal file is created by the IDE in the project name. the hex file is
downloaded to the memories of the target processor.
10. What are the debuggers used to test the embedded systems?
Many tools are used for debugging and testing embedded systems. A few of them are
Remote debugger: for monitoring and debugging the state of the embedded system
software
In Circuit Simulator: for monitoring and controlling the state of the processor in the
embedded systems
Simulators: used before the design of the embedded systems and are used to simulate the
functioning of the ES on the host machine
Logic analyzer: used to check the logical level of the various components of the ES
Oscilloscopes: to checking the analog signal and also for hardware debugging

67
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

FSM IMPLEMENTATION ON FPGA

1. Name any two applications based on FSM?


I2C bus, SPI Bus
2. What are the various types modeling in Verilog HDL?
Data flow, Gate level, Switch level, behavior model
3. What type of modeling involved in FSM design code?
Behavior model
4. Differentiate between Verilog HDL and C language?
Embedded C Language Verilog HDL
Sequential language Concurrent language
Used for algorithm based modeling the Used for detailed hardware
system implementation

5. Differentiate between Microcontroller and FPGA.


Microcontroller FPGA.
Programmable device that can be used as a programmable devices that can be used to
processing device in system design implement digital logic
ALU, memory, control unit, UART, ADC, Internally logic cell based hardware which
DAC, etc. are the internal hardware imitates the any hardware logic
Microcontrollers are custom built mini FPGAs are only composed of logic blocks
computers in an IC that can be rewired electrically
There are ready built microcontrollers being FPGAs take a considerably longer time to
sold for specific uses set-up

APPLICATION: SPEED CONTROL OF STEPPER MOTOR


TEMPERATURE MONITORING SYSTEM

1. What are the steps involved in embedded application design?


Thoroughly analyze the specification, hardware development, software
development, hardware software integration, Verification, validation.

2. How do you control the speed of the stepper motor?


The various speed levels are programmed with the help of delay program. By
pressing switches in the 4x4 matrix, the corresponding programs are called.
3. How can you make this application to work with wireless module?

If we add the UART programming with the existing code, the data can be transmitted
/received through either TXD/RXD. We can easily interface wireless modules with LPC
2148 microcontroller.
4. Draw the circuit diagram of LM 35 Temperature Sensor?
To evaluate the analog to digital conversion capabilities of the microcontroller, a LM35
temperature sensor(IC6) and a thumbwheel potentiometer(POT1) are provided on the board. The
two are connected to the same analog channel,ADC7 of the microcontroller. Either can be selected
by using jumper J2. The LM35 is powered by +5V coming from the USB bus.

68
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

5.How do you transfer the from USB-UART and viceversa?


The Stellaris Guru kit uses a FT232RL (IC4) USB to Serial bridge connected between
UART0 of the microcontroller and the USB. This helps in field programming of the
microcontroller over UART using the supplied boot loader. The port can also be used to
send UART values to a PC application ,viz. Hyper Terminal, Bray++, etc . The
connections for theFT232RLare shown in Figure

PARTITIONING BETWEEN ARM and FPGA


1. What is LFSR?
A linear feedback shift register is a shift register whose input bit is a linear function
of its previous state.
2. What is seed?
The initial value of the LFSR is called seed, and because the operation of the register is
completely determined by its current state.
3. What are taps?
The output that influences the inputs are called taps.
4. What is the use of parallel LFSR>
The parallel architecture of an LFSR reduces dynamic power consumption and can
generate more than one bit output per clock cycle.

69
SEC - ECE EMBEDDED SYSTEMS LAB RECORD

5. What is encryption?.
Encryption is the process of translating plain text data (plain text) into something that
appears to be random and meaningless (cipher text)
6. What is decryption and symmetric encryption?
Decryption is the process of converting cipher text back to plaintext. To encrypt more than
a small amount of data, symmetric encryption is used. A symmetric key is used during
both the encryption and decryption processes. To decrypt a particular piece of cipher text,
the key that was used to encrypt the data must be used.
7. What are the properties of maximum length sequence?
7 clock cycles to repeat
maximal length = 2n-1
the number of ones in the sequence are greater than the number of zero.
_ the rail occurs as 2(n-1)-1

70