SEC - ECEEMBEDDED 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; } } 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; } } SWITCH SAMPLE OUTPUT 1 SEC - ECE EMBEDDED SYSTEMS LAB RECORD EX NO: VERIFICATION AND VALIDATION USING Keil IDE AIM DATE: To verify and validate the given applications using industry standard Integrated Development Environment Keil µ vision ARM-MDK. LED Display, Stepper motor, Switch interfacing. TOOLS REQUIRED: S.NO 1 2 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. RESULT: Thus the switch, stepper motor interfacing programs were verified and validated successfully. Name Keil µvision4 ARM 7-LPC 2148 Type IDE Microcontroller 2 SEC - ECE EMBEDDED SYSTEMS LAB RECORD 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 } 3 SEC - ECE EMBEDDED SYSTEMS LAB RECORD EX NO: DATE: VERIFICATION AND VALIDATION USING RTOS AIM To verify and validate the multitasking applications using industry standard open source RTOS. TOOLS REQUIRED: S.NO 1 2 3 Name Triton Flash Fusion µC-OS-II Type IDE Fusing software RTOS HARDWARE REQUIRED: S.NO 1 2 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 Name ARM 7 - LPC 2148 DC source Type Microcontroller kit (0-12)V Quantity 1 1 RESULT: Thus the multitasking and message queue programs were verified and validated successfully. 4 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++) { } GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_5, GPIO_PIN_5); for(count=0;count<200000;count++) { } } } 5 SEC - ECE EMBEDDED SYSTEMS LAB RECORD EX NO: DATE: VERIFICATION AND VALIDATION USING OPEN SOURCE SOFTWARE AIM To verify and validate the LED blinking and RGB Pattern applications using industry standard open source ECLIPSE IDE. TOOLS REQUIRED: S.NO Name 1 Eclipse 2 LM Flash 3 GNU Make 4 Stellaris Ware 5 FTDI VCP HARDWARE REQUIRED: S.NO 1 Name CortexM3-LM3S608 µC Type IDE Programmer ARM Tool Chain Driver library USB Driver Type Microcontroller kit Quantity 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. 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. Result: Thus the above applications are verified and validated using open source eclipse IDE for ARM Cortex M3 –LM3s608 Microcontroller. 6 SEC - ECE EMBEDDED SYSTEMS LAB RECORD a) BUZZER Port Pin No Description P0.7 b) LED LED No Port Pin No Description 1 2 3 4 5 6 7 8 c) RELAY Port Pin No Description P1.26 d) 7 SEGMENT Sl no Port Pin No Description 1 2 3 4 5 6 7 8 9 10 11 12 P1.16 P1.17 P1.18 P1.19 P1.20 P1.21 P1.22 P1.23 P0.28 P1.24 P0.25 P0.11 A B C D E F G . (dp)H S1 S2 S3 S4 7 Buzzer P0.15 P0.16 P0.17 P0.18 P0.19 P0.20 P0.21 P0.22 LED 8 LED 7 LED 6 LED 5 LED 4 LED 3 LE0 2 LED 1 Relay 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) UART. TOOLS REQUIRED: S.NO 1 2 Name Triton Flash Fusion Type IDE Fusing software HARDWARE REQUIRED: S.NO 1 2 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 Name ARM 7 - LPC 2148 DC source Type Microcontroller kit (0-12)V Quantity 1 1 8 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(); }} 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(); } } 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; } } void delay() { int i,j; for(i=1;i<15000;i++); for(j=0;j<15000;j++); } *IOCLR0= 0X00000080; delay(); *IOCLR0=0x007F8000; delay(); delay(); *IOCLR1=0x04000000; delay(); 9 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 LED‟s load the IOSET0 register value as logic one between the Port Pins (P0.15 & P0.22 Call the Delay Program. To turn OFF the LED‟s 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 10 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; *IOSET1=0X00060000; delay(); *IOCLR1=0X00060000; *IOSET1=0X005B0000; delay(); *IOCLR1=0X005B0000; *IOSET1=0X004F0000; delay(); *IOSET1=0X004F0000; *IOSET1=0X00660000; delay(); *IOCLR1=0X00660000; *IOSET1=0X006D0000; delay(); *IOCLR1=0X006D0000; *IOSET1=0X003C0000; delay(); *IOCLR1=0X003C0000; *IOSET1=0X00070000; delay(); *IOCLR1=0X00070000; *IOSET1=0X007F0000; delay(); *IOCLR1=0X007F0000; *IOSET1=0X00670000; delay(); *IOCLR1=0X00670000; *IOSET1=0X00770000; delay(); *IOCLR1=0X00770000; *IOSET1=0X007F0000; delay(); *IOCLR1=0X007F0000; *IOSET1=0X00390000; delay(); *IOCLR1=0X00390000; *IOSET1=0X003F0000; delay(); *IOCLR1=0X003F0000; *IOSET1=0X00790000; delay(); *IOCLR1=0X00790000; *IOSET1=0X00710000; delay(); *IOCLR1=0X00710000; }} delay(); delay() delay(); delay(); delay(); delay(); delay(); delay(); delay(); delay(); delay(); delay(); delay(); delay(); delay(); 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 data‟s (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 11 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). 12 SEC - ECE EMBEDDED SYSTEMS LAB RECORD d) 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); lcdout('E'); lcdout('C'); lcdout('E'); lcdout('C'); lcdout('S'); lcdout(' '); } 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; return; } void lcdout(unsigned int data) { *IOCLR1=0x00ff0000; *IOSET0=DIOW; data = data << 16; *IOSET1 = data; *IOSET0=RS; return; } command(0x01); lcdout('E'); lcdout(' '); lcdout('L'); lcdout(' '); lcdout(' '); lcdout('A'); lcdout('S'); lcdout('E'); lcdout('B'); delay(); *IOSET0=RS; delay(); delay(); *IOCLR0=RS; e) 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)); 13 SEC - ECE EMBEDDED SYSTEMS LAB RECORD 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-segment LED, 2x16 LCD, and UART. 14 SEC - ECE EMBEDDED SYSTEMS LAB RECORD STATE DIAGRAM RESET=1 S0 S1 S2 S3 S4 S5 S6 6 S7 RTL DIAGRAM 15 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 1 Name FPGA spartan3 xc3s400 pq208 -4 2 Xilinx 9.1 Type Device architecture, device package speed grade 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 16 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; count=0; end 17 SEC - ECE EMBEDDED SYSTEMS LAB RECORD `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. 18 SEC - ECE EMBEDDED SYSTEMS LAB RECORD MULTIPLE OUTPUT PARALLEL LFSR ORDER 3 TRUTH TABLE Present state 100 111 100 111 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 19 1,3 101 1 10 101 110 1,2 111 100 111 CLK 1 1 1 1 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 1 2 NAME Triton Xilinx 9.1 TYPE IDE ISE HARDWARE REQUIRED SL.NO 1 2 NAME LPC2148 FPGA spartan3 xc3s400 pq208 -5 3 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 x + x+1. The structure shown is called a serial architecture. If a polynomial is primitive, the corresponding LFSR can produce 2 -1 distinct patterns. n TYPE Micro controller kit Device Architecture, Device number Package Speed grade (0-12)V QUANTITY 1 1 DC Source 1 3 20 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 MESSAGE ALGORITHM UART TRANSMITTER TXD NET "clk" LOC = P79; NET "reset" LOC = P21; NET "sin<0>" LOC = P27; NET "sin<1>" LOC = P29; NET "sin<2>" LOC = P35; NET "sout<0>" LOC = P20; NET "sout<1>" LOC = P26; NET "sout<2>" LOC = P28; NET "sout<3>" LOC = P34; NET "sout<4>" LOC = P36; NET "sout<5>" LOC = P39; NET "sout<6>" LOC = P42; 21 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 x + 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 flipflop 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 x + 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). 3 3 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 2 r-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 22 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 RXD RECEIVER ALGORITHM DECRYPTION MESSAGE TO LED‟S 23 SEC - ECE EMBEDDED SYSTEMS LAB RECORD RUN PROPERTY: The m n means the sub sequence of identical symbols 1‟s or 0‟s.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 length„r‟, 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 pseudorandom number generator (PRNG) with properties that make it suitable for use in cryptography. Many aspects of cryptography require random numbers, for example: Key generation 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. 24 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; } 25 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. 26 SEC - ECE EMBEDDED SYSTEMS LAB RECORD 4X4 MARTIX KEYPAD 27 SEC - ECE EMBEDDED SYSTEMS LAB RECORD EXNO: SPEED CONTROL OF STEPPER MOTOR AIM DATE: To develop an application to control the Stepper motor speed using LPC 2148 microcontroller. TOOLS REQUIRED: S.NO 1 2 Name Triton Flash Fusion Type IDE Fusing software HARDWARE REQUIRED: S.NO 1 2 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 Name ARM 7 LPC 2148 DC source Type Microcontroller kit (0-12)V Quantity 1 1 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; 28 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; 29 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; *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; *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) { 30 //Display 4 //Display 0 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; 31 //Display 2 SEC - ECE EMBEDDED SYSTEMS LAB RECORD delay(); *IOCLR1 = 0Xff0000; } *IOCLR0=0x00800FBF; *IOSET0=0x00000040; if((*IOPIN0&0x0000003C)==0x00000004) { sendchar0('F'); *IOSET1 = 0x710000; delay(); *IOCLR1 = 0xff0000; } else if((*IOPIN0&0x0000003C) == 0x00000008) { sendchar0('B'); *IOSET1 = 0x7c0000; delay(); *IOCLR1 = 0xff0000; } else if((*IOPIN0&0x0000003C)==0x00000010) { sendchar0('7'); *IOSET1 = 0x070000; delay(); *IOCLR1 = 0Xff0000; } else if((*IOPIN0&0x0000003C)==0x00000020) { sendchar0('3'); *IOSET1 = 0x4f0000; delay(); *IOCLR1 = 0Xff0000; }}}} //Display F //Display B //Display 7 RESULT Thus the Stepper motor speed was controlled by using ARM 7 - LPC 2148 RISC microcontroller. 32 SEC - ECE EMBEDDED SYSTEMS LAB RECORD APPENDIX A 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 3) Select debug, Release , Show all project types and show all configurations then give Next 33 SEC - ECE EMBEDDED SYSTEMS LAB RECORD 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 5) Right Click on the project folder to Select the Build mode in Active build configurations, Build and 34 SEC - ECE EMBEDDED SYSTEMS LAB RECORD Rebuild operations 35 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 36 SEC - ECE EMBEDDED SYSTEMS LAB RECORD Circuit Diagram: Switches and LEDs- circuit diagram Fig. switch Fig. LED 37 SEC - ECE EMBEDDED SYSTEMS LAB RECORD APPENDIX B: HOW TO CREATE PROJECT USING ECLIPSE IDE 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. 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 38 SEC - ECE EMBEDDED SYSTEMS LAB RECORD the kit. (Refer Appendix C) 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. 39 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. Your screen should look similar to it! 40 SEC - ECE EMBEDDED SYSTEMS LAB RECORD 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. Step 7: Go to Project Properties. Under Settings -> Tool Settings -> ARM Sourcery Windows GCC C Compiler -> Directories. 41 SEC - ECE EMBEDDED SYSTEMS LAB RECORD Step 8: Include all directory paths as shown in the above Figure. Step 9: Setting up code optimization. 42 SEC - ECE EMBEDDED SYSTEMS LAB RECORD Step 10: Including the linker. In the Project Properties window, go to Tool Setting -> ARM Sourcery Windows GCC C Linker -> General. Step 11: Add the libraries. In the Project Properties window go to Tool Setting -> ARM Sourcery 43 SEC - ECE EMBEDDED SYSTEMS LAB RECORD Windows GCC C Linker ->Libraries. Add the two directory paths as shown in Figure. Step 12: In the Project Properties window, go to C/C++ General -> Paths and Symbols -> Source 44 SEC - ECE EMBEDDED SYSTEMS LAB RECORD Location -> Link Folder. Step 13: Include the driverlib and utils folder, which contain the C source files. Your screen should look similar to it! 45 SEC - ECE EMBEDDED SYSTEMS LAB RECORD 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“ Step 15: Right click on the project opened in the workspace, go to Build Configurations and build 46 SEC - ECE EMBEDDED SYSTEMS LAB RECORD and clean the project. Step 16: Go to Run -> External Tools -> External Tools Configuration 47 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. Step 19: Go to the Program tab, and select the .bin file by browsing to your project in the Eclipse 48 SEC - ECE EMBEDDED SYSTEMS LAB RECORD 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. APPENDIX C 49 SEC - ECE EMBEDDED SYSTEMS LAB RECORD LPC 2148 PIN selection and CPU Registers Binary Value 00 01 10 11 function First alternate function Primary (default) function (always GPIO) Second Alternate function Third Alternate function Fourth alternate function PINSEL0 Register Lower order two bytes PINSEL1 Register higher order bytes 50 SEC - ECE EMBEDDED SYSTEMS LAB RECORD PINSEL2 Register 51 SEC - ECE EMBEDDED SYSTEMS LAB RECORD UART0 Line Status Register Bit Description: U0LSR Function Description Receiver Data Ready (RDR) Overrun Error (OE) Parity Error (PE) Framing Error (FE) Break Interrupt (BI) Transmitter Holding Register Empty (THRE) Transmitter Empty (TEMT) 0: U0RBR is empty 1: U0RBR contains valid data U0LSR0 is set when the U0RBR holds an unread character and is cleared when the UART0 RBR FIFO is empty. 0: Overrun error status is inactive. 1: Overrun error status is active. Reset Value 0 0 1 0 2 0: Parity error status is inactive. 1: Parity error status is active. 0: Framing error status is inactive. 1: Framing error status is active. 0: Break interrupt status is inactive. 1: Break interrupt status is active. 0: U0THR contains valid data. 1: U0THR is empty. THRE is set immediately upon detection of an empty UART0 THR and is cleared on a U0THR write. 0: U0THR and/or the U0TSR contains valid data. 1: U0THR and the U0TSR are empty. TEMT is set when both U0THR and U0TSR are empty; TEMT is cleared when either the U0TSR or the U0THR contain valid data. 0: U0RBR contains no UART0 Rx errors or U0FCR0=0. 1: UART0 RBR contains at least one UART0 Rx error. 0 3 0 4 0 5 1 6 1 7 Error in Rx FIFO (RXFE) 0 Baud Rate Calculation: Clock frequency / (16 * baud rate) = decimal Hex DLM & DLL 52 SEC - ECE EMBEDDED SYSTEMS LAB RECORD UART0 Line Control Register Bit Description: U0 Function Description LCR 00: 5 bit character length Word Length 1:0 01: 6 bit character length Select 10: 7 bit character length 11: 8 bit character length 2 Stop Bit Select 0: 1 stop bit 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. Error (FE) 00: Odd parity 01: Even parity 5:4 Parity Select 10: Forced “1” stick parity 11: Forced “0” stick parity 0: Disable break transmission 1: Enable break transmission. 6 Break Control Output pin UART0 TxD is forced to logic 0 when U0LCR is active high. Divisor Latch 0: Disable access to Divisor Latches 7 Access Bit 1: Enable access to Divisor Latches ADCR A/D CONTROL REGISTER ADCR 23:22 Function Description Reset Value 0 0 0 0 0 0 Reset Value NA 26:24 START 27 EDGE Reserved, user software should not write ones to reserved bits. The 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 isstarted: 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. 011 Start conversion when the edge selected by bit 27 occurs on 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: Start conversion on a falling edge on the selected CAP/MAT signal. 0 Start conversion on a rising edge on the selected CAP/MAT signal. 0 0 31:28 - user software should not write ones to reserved bits. The value read from a Reserved, reserved bit is not defined. NA 53 SEC - ECE EMBEDDED SYSTEMS LAB RECORD APPENDIX D 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. 54 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. 55 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 bitpacked 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. 56 SEC - ECE EMBEDDED SYSTEMS LAB RECORD VERIFICATIONAND VALIDATION USING KEIL IDE 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 can‟t convert the appropriate machine code for the target processor. The supporting data‟s cannot be taken. 14. What are various integer initialization types? 57 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 data‟s 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 can‟t 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 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 7. 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 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? 58 SEC - ECE EMBEDDED SYSTEMS LAB RECORD Embedded C Language Sequential language Used for algorithm based system Verilog HDL Concurrent language modeling the Used for detailed implementation hardware 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 Expt 5 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 module 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. PARTITIONING BETWEEN ARM AND FPGA 1. What is LFSR? A linear feedback shift register (LFSR) 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 deterministic, the stream of values produced by the register is completely determined by its current (or previous) state. 3. What are taps? The outputs that influence 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. 5. What are the applications of LFSRs? Applications of LFSRs include generating pseudo-random numbers, pseudo-noise sequences, fast digital counters, and whitening sequences. 6. What is encryption? Encryption is the conversion of data into a form, called a cipher text, that cannot 59 SEC - ECE EMBEDDED SYSTEMS LAB RECORD be easily understood by unauthorized people. 7. What is decryption? Decryption is the process of converting encrypted data back into its original form, so it can be understood. 8. What is 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). 9. What are the properties of maximum length sequence? 1. When the PN sequence generated by linear feed back shift register has the length of 2r-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 random sequence ones and zeros are equally probable. Maximal length sequence: Tc , Tb=NTc. 60