EMBEDDED SYSTEM DESIGN (NORTH MAHARASHTRA UNIVERSITY) EMBEDDED LABORATORY SOLUTIONS FROM OASIS TECHNOLOGIES PRIVATE LIMITED www.oasistech.co.in 203, Eden Hall Opp. OM Super Market Model Colony Shivajinagar, Pune – 411016 Maharashtra, India Phone: +91-20-65236642 / 64000203 Fax: +91-20-25661715 Email: sales @oasistech.co.in [email protected]1
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
EMBEDDED SYSTEM DESIGN(NORTH MAHARASHTRA UNIVERSITY)
Learning Manual for Embedded Design Laboratory as per
North Maharashtra University Curriculum
Dear Faculty Member,
Oasis Technologies is a leading provider of single board computer and embedded systems solutions. We offer a variety of solutions that range from the standard off-the-shelf single board computer products and embedded operating systems to completely custom-designed solutions and intellectual property solutions.
We have extensive experience in the area of ARM processor technology. Our product portfolio includes embedded software tools and ARM based reference boards which are highly popular in the area of processor technology academics and in the use of such processor technology amongst the corporate sector.
Here we present a complete laboratory manual for 'Embedded System Design' subject, which is newly added in North Maharashtra University syllabus. This manual will certainly be helpful for, not only for faculty members but also for students, to learn and get hold on ARM processor technology.
Note that the data provided in meant for internal ciculation only.
For Oasis Technologies Pvt. Ltd.
2
Elective IEMBEDDED SYSTEM DESIGN
Theory : 4 Hrs/week Practical:2 Hrs/weekMarks : 100 Marks:50
T.W.25
Unit IEmbedded system Introduction
Introduction to Embedded System,History,Design challenges,optimizing design metrics,time to market,applications of embedded systems and recent trends in embedded systems,embedded design concepts and definations,memory management,hardware and software design and testing,communication protocols like SPI,SCI, I2C,CAN etc.
Unit IISystem Architecture
Introduction to ARM core architecture,ARM extension family,instruction set,thumb instruction set,Pipeline,memory management,Bus architecture,study of on-chip peripherals like I/O ports,timers,counters,interrupts,on-chip ADC,DAC,RTC modules,WDT,PLL,PWM,USB etc.
Unit IIIInterfacing and programming
Basic embedded C programs for on-chip peripherals studied in system architecture.Need of interfacing,interfacing techniques,interfacing of different displays including Graphic LCD(320 X 240),interfacing of input devices including touch sceen etc,interfacing of output devices like thermal printer etc.,embedded communication using CAN and Ethernet,RF modules,GSM modem for AT command study etc.
Unit IVReal time Operating System Concept
Architecture of kernel,task scheduler,ISR,Semaphores,mailbox,message queues, pipes, events,timers, memory management,RTOS services in contrast with traditional OS,Introduction to µCOSII,Inter-task communication in µCOSII,memory management in µCOSII,porting of RTOS.
Unit VEmbedded Linux
Introduction to the Linux kernel,Configuring and booting the kernel,The root file system,Root file directories,/bin,/lib etc.,Linux file systems,Types of file system: Disk,RAM,Flash,Network,Some debug techniques-Syslog and strace,GDB,TCP/IP Networking- Network configuration,Device control from user space- Accessing hardware directly,Multi processing on Linux and Inter Process Communicaton- Linux process model and IPCs, Multithreading using pThreads – Threads vs. Processes and pThreads,Linux and Real-Time- Standard kernel problems and patches.
Text Books1) Frank Vahid, “Embedded system design” , PHI2) Rajkamal “ Embedded Systems” , TMH3) David Simon “ Embedded Systems software primer” , Pearson4) Steve Furber “ ARM System-on-Chip Architecture” , Pearson5) Jean J. Labrose “ MicroC/OS-II” , Indian Low Price Edition
Reference Books1) Dr. K.V.K.K. Prasad “Embedded /real time systems” , Dreamtech2) Iyer Gupta “Embedded real systems Programming” ,TMH3) Steve Heath “ Embedded System Design” , Neuwans
LAB EXERCISE
1) Integrated Development Environment Overview.(Project creation,down load & debug)2) Study of JTAG Debugger / on-board debugger-emulator.3) ARM Instructions execution(Barrel Shifter,LDR/STR,SMT,LDM)
4
List Of Practicals
Group-A
1) Writing basic C-programs for I/O operations2) C-Program to exlore timers/counter3) C-Programs for interrupts4) Program to demonstrate UART operation
Group-B
5) Program to demonstrate I2C Protocol6) Program to demonstrate CAN Protocol
Group -C
7) Program to interface LCD8) Program to interface Keyboard and display key pressed on LCD9) Program to interface stepper motor
Group – D
10) Program to demonstrate RF communication11) Program to implement AT commands and interface of GSM modem12) Implementation of USB protocol and transferring data on PC13) Implementation of algorithm / program for the microcontroller for low power modes
Group – E
14) Interfacing 4x4 matrix keyboards and 16x2 character LCD display to microcontroller / microprocessor and writting a program using RTOS for displaying a pressed key
15) Writting a scheduler using RTOS for 4 tasks with priority. The tasks may be Keyboard, LCD, LED etc. And porting it on microcontroller / microprocessor
Group – F
16) Implement a semaphore for any given task switching using RTOS on microcontroller board17) Create two tasks, which will print some characters on the serial port. Start the scheduler and
observe the behavior
Group – G
18) RTOS based interrupt handling using Embedded Reat Time Linux19) Program for exploration of (Process Creation, Thread Creation) using Embedded Real Time
Linux
Group – H
20) Program for exploring Message Queues using Embedded Real Time Linux21) Ethernet based Socket Programming using Embedded Real Time Linux
5
LAB EXERCISE 1:
Objective:To write a Program for I/O operations.
Program Description:This program demonstrates blinking of LED using GPIO.
Pin Assignment : LED Display Interface
Sr.No Signal Description
1 Pin 45 (P0.15) L8
2 Pin 46 (P0.16) L7
3 Pin 47 (P0.17) L6
4 Pin 53 (P0.18) L5
5 Pin 54 (P0.19) L4
6 Pin 55 (P0.20) L3
7 Pin 1 (P0.21) L2
8 Pin 2 (P0.22) L1
Output:LED blinks continuously.
Part List :
1. OASIS ARM7( TITAN) BOARD2. RS232 Serial cable3. 9 Volt DC Power Supply4. Triton IDE
Procedure:1. Connect 9 V DC Power supply to the OASIS TITAN Board.2. Connect the board with COM port of PC using the serial cable.3. Generate .hex file using Triton IDE.4. Download the .hex file.5. Put the board in RUN mode and observe the output.
6
*****Code for led blinking in assembly language*****
Program Description:This program demonstrates blinking of LED using GPIO after specified interval.
Pin Assignment: LED Display Interface
Sr.No Signal Description 1 Pin 45 (P0.15) L8
2 Pin 46 (P0.16) L7
3 Pin 47 (P0.17) L6
4 Pin 53 (P0.18) L5
5 Pin 54 (P0.19) L4
6 Pin 55 (P0.20) L3
7 Pin 1 (P0.21) L2
8 Pin 2 (P0.22) L1
Output:LED blinks after specific interval.
Header Files: LPC21xx.h, board.h Part List :
1. OASIS ARM7( TITAN) BOARD2. RS232 Serial cable3. 9 Volt DC Power Supply4. Triton IDE
Procedure:1. Connect 9 V DC Power supply to the OASIS TITAN Board.2. Connect the Board with the COM port of the PC using the serial cable.3. Generate .hex file using Triton IDE.4. Download the .hex file.5. Put the board in RUN mode and observe the output.
8
*****Blinking of LED using GPIO after specified interval*****
Objective:To write a program for External Interrupts.
Program Description:This program demonstrates interrupts using on board EXT SWITCH
Pin Assignment :The following table lists details about the 7-Segment Display interface.
Description: 7-segment Display
Sr.No Signal Description
1 Pin 16 (P1.16) ‘ a’
2 Pin 12 (P1.17) ‘b’
3 Pin 8 (P1.18) ‘c’
4 Pin 4 (P1.19) ‘d’
5 Pin 48 (P1.20) ‘e’
6 Pin 44 (P1.21) ‘f’
7 Pin 40 (P1.22) ‘g’
8 Pin 36 (P1.23) ‘.’
9 Pin 13 (P0.28) NC
10 Pin 14 (P0.29) NC
11 GND NC
Output:
The digit on 7 Segment segment will glow after getting interrupt.
Header Files: LPC21xx.h, board.h Part List :
1. OASIS ARM7( TITAN) BOARD2. RS232 Serial cable3. 9 Volt DC Power Supply4. Triton IDE
Procedure:1. Connect 9 V DC Power supply to the OASIS TITAN Board.2. Connect the Board with the COM port of the PC using the serial cable.3. Generate .hex file using Triton IDE.4. Download the .hex file.5. Put the board in RUN mode and observe the output.
10
*****External Interrupt based 7-segment display*****#include<board.h>#include<LPC21xx.h>
Program Description:This program demonstrates UART based communication.
Pin Assignment :Refer the data sheet of LPC21xx of chapter UART. Output: A character pressed on PC keyboard, will be displayed on hyper terminal as per the designed baud rate.
Header Files: LPC21xx.h Part List :
1. OASIS ARM7( TITAN) BOARD2. RS232 Serial cable3. 9 Volt DC Power Supply4. Triton IDE
Procedure:1. Connect 9 V DC Power supply to the OASIS TITAN Board.2. Connect the Board with the COM port of the PC using the serial cable.3. Generate .hex file using Triton IDE.4. Download the .hex file.5. Put the board in RUN mode.6. Press any key on PC keyboard and observe the output on Hyper Terminal.
Program Description:This program demonstrates I2C Protocol for TITAN board in Master Transmitter and Receivermode.
Pin Assignment :Refer data sheet for I2C pin details.
Output:User can read / write data from / to external EEPROM.
Header Files: address_c.h , functions.h
Part List : 1. OASIS ARM7( TITAN) BOARD2. RS232 Serial cable3. 9 Volt DC Power Supply4. Triton IDE
Procedure:1. Connect 9 V DC Power supply to the OASIS TITAN Board.2. Connect the Board with the COM port of the PC using the serial cable.3. Generate .hex file using Triton IDE.4. Download the .hex file.5. Put the board in RUN mode and you can access external EEPROM.
15
*****I2C Test for Master Transmitter and Receiver mode*****
#include "address_c.h"#include "functions.h"
#define ENABLE 0x040#define START 0x020#define STOP 0x10#define SI 0x08#define AA 0x04
Objective:To write a Program for Controller Area Network.
Program Description:This program demonstrates CAN Protocol based communication.
Pin Assignment :Refer data sheet for CAN pin details.
Output:User can transfer data on CAN bus.
Header Files: LPC21xx.h Part List :
1. OASIS ARM7( TITAN) BOARD (2 nos.)2. RS232 Serial cable3. 9 Volt DC Power Supply4. Triton IDE
Procedure:1. Connect 9 V DC Power supply to the OASIS TITAN Board.2. Connect the Board with the COM port of the PC using the serial cable.3. Generate .hex file using Triton IDE for 'Transmitter' & “Receiver' .4. Download the .hex file for 'Transmit Routine' on one board.5. Download the .hex file for 'Receive Routine' on other board.6. Put the boards in RUN mode and you can transfer data on CAN.7. Accept 'PC Keyboard input' using Transmitter board and display the same using Hyper
Program Description:This program displays output on LCD
Pin Assignment: LCD display interface
Sr. No. Signal Description
1 Pin 16 (P1.16) Data 0
2 Pin 12 (P1.17) Data 1
3 Pin 8 (P1.18) Data 2
4 Pin 4 (P1.19) Data 3
5 Pin 48 (P1.20) Data 4
6 Pin 44 (P1.21) Data 5
7 Pin 40 (P1.22) Data 6
8 Pin 36 (P1.23) Data 7
9 Pin 13 (P0.28) RS
10 Pin 14 (P0.29) EN
11 GND WR
Output:'A string' given in code will be displayed on LCD.
Header Files: LPC21xx.h Part List :
1. OASIS ARM7( TITAN) BOARD2. RS232 Serial cable3. 9 Volt DC Power Supply4. Triton IDE
Procedure:1. Connect 9 V DC Power supply to the OASIS TITAN Board.2. Connect the Board with the COM port of the PC using the serial cable.3. Generate .hex file using Triton IDE.4. Download the .hex file.5. Put the board in RUN mode and you can observe the output.
Objective:To write a Program to interface for keypad and LCD.
Program Description:This program demonstrates LCD using keypad.
Output:Character will be displayed on LCD as per the pressed key on keyboard.
Header Files: Board.h Part List :
1. OASIS ARM7( TITAN) BOARD2. RS232 Serial cable3. 9 Volt DC Power Supply4. Triton IDE
Procedure:1. Connect 9 V DC Power supply to the OASIS TITAN Board.2. Connect the Board with the COM port of the PC using the serial cable.3. Generate .hex file using Triton IDE.4. Download the .hex file.5. Put the board in RUN mode.6. Press any key on on-board Keypad and you can observe the output on LCD.
Objective:To write a program for interface of Stepper Motor.
Program Description:This program demonstrates interfacing of Stepper Motor.
Pin Assignment :Sr. No. Signal Description
1 Pin 37 (P0.11) Data 0
2 Pin 38 (P0.12) Data 1
3 Pin 39 (P0.13) Data 2
4 Pin 41 (P0.14) Data 3
5 5.0V VCC(5)
6 GND GND
Output:Motor will rotate as per the defined sequence.
Header Files: LPC21xx.h, board.h Part List :
1. OASIS ARM7( TITAN) BOARD2. RS232 Serial cable3. 9 Volt DC Power Supply4. Triton IDE
Procedure:1. Connect 9 V DC Power supply to the OASIS TITAN Board.2. Connect the Board with the COM port of the PC using the serial cable.3. Generate .hex file using Triton IDE.4. Download the .hex file.5. Connect the stepper Motor as per the Pin diagram given in user manual.6. Now set the board into RUN mode and observe the output.
Objective:To write a program for implementing AT commands and interface of GSM modem.
Program Description:Code for interfacing the GSM module,4x4 keypad(new board) and lcd screen for doing four general mobile operation.
1. Making call2. Receiving call3. Sending SMS4. Receiving SMS and immediately displaying first 16 character of the SMS on LCD
without acknowledge.
Header Files: AT91SAM9260.h Part List :
1. OASIS ARM9(Explorer) BOARD2. Keypad plus LCD peripheral board3. GSM Modem4. GSM service SIM card5. RS232 Serial cable6. 7 Volt DC Power Supply7. Triton IDE
Procedure:1. Connect 7V DC Power supply to the OASIS EXPLORER Board.2. Connect the board with the COM port of the PC using the serial cable.3. Power ON the board and come to 'Boot Loader prompt'.4. Download the application binary file.5. Connect GSM Modem to Explorer Board. 6. Refer manual for GSM Modem and 'Oasis application notes', follow the instructions
33
/************************************************** Program for interfacing GSM with explorer board, interfacing 4x4 matrix key pad and 16x2 LCD.* For keypad port pin PA4-7 used* For LCD port pin PB0-9 from GPIO connector*************************************************/#include "AT91SAM9260.h"
Objective:To write a program for Implementation of USB
Program Description:This program demonstrates Implementation of USB
Pin Assignment :Refer the data sheet of LPC21xx of chapter USB. Output:Character will be displayed on hyper terminal as per the designed baud rate.
Header Files: string.h, print.h, type.h, usbdebug.h, console.h, usbapi.h, startup.h Part List :
1. OASIS ARM7( TITAN) BOARD with LPC21482. RS232 Serial cable3. USB Cable4. 9 Volt DC Power Supply5. Triton IDE
Procedure:1. Connect 9 V DC Power supply to the OASIS TITAN Board.2. Connect the Board with the COM port of the PC using the serial cable.3. Generate .hex file using Triton IDE.4. Download the .hex file.5. Put the board in RUN mode.6. Now you can transfer data on USB, accept PC keyboard input and display the same on
Hyper Terminal using USB cable.
46
***** Minimal implementation of a USB serial port, using the CDC class.This example application simply echoes everything it receives right backto the host.
Windows:Extract the usbser.sys file from .cab file in C:\WINDOWS\Driver Cache\i386and store it somewhere (C:\temp is a good place) along with the usbser.inffile. Then plug in the LPC214x and direct windows to the usbser driver.Windows then creates an extra COMx port that you can open in a terminalprogram, like hyper terminal
Linux:The device should be recognized automatically by the cdc_acm driver,which creates a /dev/ttyACMx device file that acts just like a regularserial port.
// call USB interrupt handler continuouslywhile (1) {
USBHwISR();}
#else q_printf("Hello");#endif
return 0;
}
52
LAB EXERCISE 14:
Objective:To write a program for interfacing on-board Keypad & LCD, using RTOS .
Program Description:This program RTOS based Keypad & LCD interfacing.
Output:A key, pressed on Keypad is displayed on LCD.
Header Files: board.h, ucos.h, lcd.h, keyboard.h Part List :
1. OASIS ARM7( TITAN) BOARD2. RS232 Serial cable3. 9 Volt DC Power Supply4. Triton IDE
Procedure:1. Connect 9 V DC Power supply to the OASIS TITAN Board.2. Connect the Board with the COM port of the PC using the serial cable.3. Generate .hex file using Triton IDE.4. Download the .hex file.5. Put the board in RUN mode.6. Press any key on on-board Keypad and you can observe the output on LCD.
53
*****Code to read key and display it on LCD***** #include<board.h>#include<ucos.h>#include<lcd.h>#include<keyboard.h>
Objective:To write a program for RTOS for 3 tasks.
Program Description:This program demonstrates RTOS context switching .
Output:On-board LEDs will glow in defined pattern.
Header Files: LPC21xx.h, board.h ,ucos.h Part List :
1. OASIS ARM7( TITAN) BOARD2. RS232 Serial cable3. 9 Volt DC Power Supply4. Triton IDE
Procedure:7. Connect 9 V DC Power supply to the OASIS TITAN Board.8. Connect the Board with the COM port of the PC using the serial cable.9. Generate .hex file using Triton IDE.10. Download the .hex file.11. Put the board in RUN mode and you can observe the LED output.
55
*****Creating three different tasks and context switching between three tasks***** #include <LPC21xx.H> #include <ucos.h>#include <board.h>
Objective:To write a Program to implement a semaphore for any given task using RTOS
Program Description:This program demonstrates RTOS semaphore .
Output:On-board LEDs will glow in defined pattern.
Header Files: LPC21xx.h, lcd.h, ucos.h Part List:
1. OASIS ARM7( TITAN) BOARD2. RS232 Serial cable3. 9 Volt DC Power Supply4. Triton IDE
Procedure:1. Connect 9 V DC Power supply to the OASIS TITAN Board.2. Connect the Board with the COM port of the PC using the serial cable.3. Generate .hex file using Triton IDE.4. Download the .hex file.5. Put the board in RUN mode and you can observe the LED output.
59
***** Describing the semaphore behavior within two different tasks*****
Objective:To write a Program to implement a context switching using RTOS
Program Description:This program demonstrates context switching .
Output:Strings defined in two different tasks are printed on Hyper Terminal.
Header Files: ucos.h, Board.h Part List:
1. OASIS ARM7( TITAN) BOARD2. RS232 Serial cable3. 9 Volt DC Power Supply4. Triton IDE
Procedure:1. Connect 9 V DC Power supply to the OASIS TITAN Board.2. Connect the Board with the COM port of the PC using the serial cable.3. Generate .hex file using Triton IDE.4. Download the .hex file.5. Put the board in RUN mode and you can observe the output on Hyper Terminal.
Objective:To write a Program to implement a Process creation using Explorer Board
Program Description:This program demonstrates Process creation using Linux on Explorer Board.
Output:Strings from two different processes are displayed on Hyper Terminal.
Header Files: stdlib.h, stdio.h, unistd.h Part List:
1. OASIS ARM9( Explorer) BOARD2. RS232 Serial cable3. 7 Volt DC Power Supply4. Ethernet Cross cable5. Triton IDE
Procedure:1. Connect 9 V DC Power supply to the OASIS Explorer Board.2. Connect the Board with the COM port of the PC using the serial cable.3. Connect the Ethernet cable.4. Generate .out file using Triton IDE.5. Download the .out file using TFTP.6. Observe the output on Hyper Terminal.
65
*****FORK which creates PID for child process and parent process*****
if(pid == 0) { /* Child process: * When fork() returns 0, we are in * the child process. * Here we count up to ten, one each second. */ int j; for(j=0; j < 10; j++) { printf("child: %d\n", j); sleep(1); } _exit(0); /* Note that we do not use exit() */ } else if(pid > 0) { /* Parent process: * Otherwise, we are in the parent process. * Again we count up to ten. */ int i; for(i=0; i < 10; i++) { printf("parent: %d\n", i); sleep(1); } } else { /* Error handling. */ fprintf(stderr, "couldn't fork"); exit(1); } return 0;}
66
LAB EXERCISE 20:
Objective:To write a Program to implement a Message Queue using Explorer Board
Program Description:This program demonstrates use of Message Queue using Linux on Explorer Board.
Output:Output, as defined in the code, is available on Hyper Terminal.
1. OASIS ARM9(Explorer) BOARD2. RS232 Serial cable3. 7 Volt DC Power Supply4. Ethernet Cross cable5. Triton IDE
Procedure:1. Connect 9 V DC Power supply to the OASIS Explorer Board.2. Connect the Board with the COM port of the PC using the serial cable.3. Connect the Ethernet cable.4. Generate .out file using Triton IDE.5. Download the .out file using TFTP.6. Observe the output.
67
*****Receiver program which contains the Message Queue identifier with 'msgget' and then receive messages until "end" is received*****
Objective:To write a Program to implement a Socket using Explorer Board
Program Description:This program demonstrates using a Socket using Linux on Explorer Board.
Output:
Header Files: sys/types.h, sys/socket.h, sys/un.h, stdio.h, unistd.h Part List:
1. OASIS ARM9(Explorer) BOARD2. RS232 Serial cable3. 7 Volt DC Power Supply4. Ethernet Cross cable5. Triton IDE
Procedure:1. Connect 9 V DC Power supply to the OASIS Explorer Board.2. Connect the Board with the COM port of the PC using the serial cable.3. Connect the Ethernet cable.4. Generate .out file using Triton IDE.5. Download the .out file using TFTP.6. Observe the output.