Professional Documents
Culture Documents
AT91RM9200
Workbook
____________________________________________________________________________
______________________________________________________________
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
______________________________________________________________
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
USB 2.0 Full Speed (12 Mbits per second) Device Port
1. On-chip Transceiver, 2-Kbyte Configurable Integrated FIFOs
Multimedia Card Interface (MCI)
1. Automatic Protocol Control and Fast Automatic Data Transfers
2. MMC and SD Memory Card-compliant, Supports Up to Two SD Memory Cards
Three Synchronous Serial Controllers (SSC)
1. Independent Clock and Frame Sync Signals for Each Receiver and Transmitter
2. I2S Analog Interface Support, Time Division Multiplex Support
3. High-speed Continuous Data Stream Capabilities with 32-bit Data Transfer
Four Universal Synchronous/Asynchronous Receiver/Transmitters (USART)
1. Support for ISO7816 T0/T1 Smart Card
2. Hardware and Software Handshaking
3. RS485 Support, IrDA Up To 115 Kbps
4. Full Modem Control Lines on USART1
Master/Slave Serial Peripheral Interface (SPI)
1. 8- to 16-bit Programmable Data Length, 4 External Peripheral Chip Selects
Two 3-channel, 16-bit Timer/Counters (TC)
______________________________________________________________
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
1. Three External Clock Inputs, Two Multi-purpose I/O Pins per Channel
2. Double PWM Generation, Capture/Waveform Mode, Up/Down Capability
Two-wire Interface (TWI)
1. Master Mode Support, All 2-wire Atmel EEPROMs Supported
IEEE 1149.1 JTAG Boundary Scan on All Digital Pins
Power Supplies
1. 1.65V to 1.95V for VDDCORE, VDDOSC and VDDPLL
2. 1.65V to 3.6V for VDDIOP (Peripheral I/Os) and for VDDIOM (Memory I/Os)
Available in a 208-lead PQFP or 256-ball BGA Package
______________________________________________________________
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
______________________________________________________________
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
______________________________________________________________
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Register 15 is the Program Counter (PC) and can be used in all instructions to
reference data relative to the current instruction.
R14 holds the return address after a subroutine call.
R13 is used (by software convention) as a stack pointer.
1.4.4.1 Registers used in Operating Modes:
Register R0 to R7 are unbanked registers, thus each of them refers to the same 32bit physical register in all processor modes. They are general purpose registers, with
no special uses managed by the architecture, and can be used wherever an
instruction allows a general purpose register to be specified.
______________________________________________________________
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Registers R8 to R14 are banked registers. This means that each of them depends of
the current processor mode.
1.4.4.2 Modes and Exception Handling
All exceptions have banked registers for R14 and R13.
After an exception, R14 holds the return address for exception processing. This
address is used both to return after the exception is processed and to address the
instruction that caused the exception.
R13 is banked across exception modes to provide each exception handler with a
private stack pointer.
The fast interrupt mode also banks registers 8 to 12 so that interrupt processing can
begin without the need to save these registers.
A seventh processing mode, System Mode, does not have any banked registers. It
uses the User Mode registers. System Mode runs tasks that require a privileged
processor mode and allows them to invoke all classes of exceptions.
1.4.4.3 Status Registers
All other processor states are held in status registers. The current operating
processor status is in the Current Program Status Register (CPSR). The CPSR holds:
Four ALU flags (Negative, Zero, Carry, and Overflow),
Two interrupt disable bits (one for each type of interrupt),
One bit to indicate ARM or Thumb execution
Five bits to encode the current processor mode
All five exception modes also have a Saved Program Status Register (SPSR) which
holds the CPSR of the task immediately before the exception occurred.
______________________________________________________________
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
______________________________________________________________
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
______________________________________________________________ 10
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
______________________________________________________________ 11
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
1.4.8.1 Domain
A domain is a collection of sections and pages. The ARM920T supports 16 domains.
Access to the domains is controlled by the Domain Access Control register.
1.4.8.2 MMU Faults
The MMU generates alignment faults, translation faults, domain faults and
permission faults.
Alignment fault checking is not affected by whether the MMU is enabled or not.
The access controls of the MMU detect the conditions that produce these faults. If
the fault is a result of memory access, the MMU aborts the access and signals the
fault to the CPU core. The MMU stores the status and address fault in the FSR and
FAR registers (only for faults generated by data access).
The MMU does not store fault information about faults generated by an instruction
fetch.
______________________________________________________________ 12
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
______________________________________________________________ 13
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
______________________________________________________________ 14
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Size
16kB
128kB
32MB
8MB
Start address
0x00200000
0x00100000
0x20000000
0x10000000
End address
0x0021f400
0x001fa000
0x22000000
0x10400000
______________________________________________________________ 15
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Reference
J4
Memory Location
Start
End
0XFFFB0000
0XFFFB4000
ID
J5
0XFFFB0000
0XFFFB4000
23
Ethernet
J13
0XFFFBC000
0XFFFC0000
24
UART0
J3
0XFFFC0000
0XFFFC4000
06
DBGU
J1
0XFFFFF200
0XFFFFF400
07
TWI
U8
0XFFFB8000
0XFFFBC000
12
SPI
J8
0XFFFE0000
0XFFFE4000
13
MCI
J6
0XFFB4000
0XFFFB8000
10
SSC
J7
0XFFFD0000
0XFFFD4000
14
PORT A
J11
0XFFFFF400
0XFFFFF600
02
PORT B
J12
0XFFFFF000
0XFFFFF800
03
11
______________________________________________________________ 16
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
______________________________________________________________ 17
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Power Jumper: JMP4 and JMP5, connect this jumper which is near supply on
board.
______________________________________________________________ 18
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Signal
PA0
PA1
PA2
PA3
PA4
PA5
PA6
PA17
PA18
PA19
PA20
PA21
PA22
PA23
PA24
PA25
PA26
3.3V
5.0 V
GND
Function
MISO/PCK3
MOSI/PCK0
SPCK/IRQ4
NPCS0/IRQ5
NPCS1/PCK1
NPCS2/TXD3
NPCS3/RXD3
TXD0/TIOA0
RXD0/TIOB0
SCK0/TIOA1
CTS0/TIOB1
RTS0/TIOA2
RXD2/TIOB2
TXD2/IRQ3
SCK2/PCK1
TWD/IRQ2
TWCK/IRQ1
______________________________________________________________ 19
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
SIGNAL
PB0
PB1
PB2
PB3
PB4
PB5
PB6
PB7
PB8
PB9
PB10
PB11
PB20
PB21
PB22
PB23
PB24
3.3V
5.0V
GND
FUNCTION
TF0/RTS3
TK0/CTS3
TD0/SCK3
RD0/MCDA1
RK0/MCDA2
RF0/MCDA3
TF1/TIOA3
TK1/TIOA3
TD1/TIOA4
RD1/TIOB4
RK1/TIOA5
RF1/TIOB5
TXD1
RXD1
SCK1
DCD1
CTS1
______________________________________________________________ 20
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
SIGNAL
3.3V
3.3V
NTRST
GND
TDI
GND
TMS
GND
TCK
GND
GND
GND
TDO
GND
NRST
GND
NC
GND
NC
GND
signal
Pa27
Pa28
Pa29
Pb3
Pb4
Pb5
Vcc
Gnd
Vcc
Gnd
function
MCCK
MCCDA
MCDA0
MCDA1
MCDA2
MCDA3
3.3
Gnd
3.3
Gnd
______________________________________________________________ 21
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
2.7.5 SCC J7
Pin
1
2
3
4
5
6
7
8
9
10
Signal
Pb8
Pb9
Pb10
Pb11
Pb12
function
TDI
RDI
TK
RK1
TF1
______________________________________________________________ 22
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
4. Viewing CD Contents
4.1 Introduction:
The distribution DVD contains all the necessary files required to work with the ARM9
target systems. The following is the list of the contents:
Images
ARM-9 Tool Chain
source code
Setup Utilities
Board manual
Utilities
tftp32 utility
winscp utility
putty utility
ARM IDE setup
Board manual
ARM9 board manual
Note:
Here programs given in the CD content at sourcecode/exercises folder/directory
are the reference programs for the exercises given after each lab programs.
______________________________________________________________ 23
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Installing
Installing
Installing
Installing
the
the
the
the
This session explains how to install toolchain for ARM-9 target board
Note that separate version of Linux are used by the target and the host Linux
PC.
The following Linux host operating system is supported for use with the
ARM9 target board.
o
To install the ARM9 toolchain, follow this step:1. Log in as root on your host Linux PC.
2. Copy the build_root.tar from the Edutech DVD to the /opt folder.
3. Now type the following command to Un-tar (Un-zip) the build_root.tar
4. [root@EDUTECH] tar vxf build_root.tar.
5. This command will take approx 5 min for execution.
6. After executing this command you will see a folder build_root in the /opt
folder.
7. As the folder is created, it means your toolchain has successfully installed.
______________________________________________________________ 24
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
______________________________________________________________ 25
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
4. Now click on the Next button ,then you see the below window.
5. Again click on Next button ,you will see the below window.
______________________________________________________________ 26
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
6. Now select the Norton Commander interface and click Next and you will see
below window.
______________________________________________________________ 27
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
7. Now
Click the Install button.
8. Now select the Yes, restart the computer now and click on Finish button.
9. Now click on the Icon as soon below, from your desktop.
Winscp.lnk
______________________________________________________________ 28
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
10. After clicking that Icon you will see the below window.
10
11. Enter the Host name:, User
______________________________________________________________ 29
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
12. After Login, you will see the below window. In this window on right hand side is
the Linux window/Host window, left hand side is the Window PC window/remote
window. Now you can copy your data from Host PC to Remote PC and Via-Versa.
______________________________________________________________ 30
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
______________________________________________________________ 31
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
______________________________________________________________ 32
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
______________________________________________________________ 33
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Shortcut to tftpd32.exe.lnk
______________________________________________________________ 34
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
5. Click on browse option and select appropriate path from which you want to
transfer the file to ARM9 target system.
______________________________________________________________ 35
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
5.5.2 Additional software requirement: If a window ME/NT/2000/XP is used, you must have to
download the windows installer in your PC.
For installing ARM IDE you must check whether .NET Frame
Work is installed in your PC. If it is not installed, see the
procedure given below.
5.5.3 Installation of .NET Frame Work: Open the CD ROM.
Double click on the dotnetfx folder shown below.
click on Install.
______________________________________________________________ 36
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Click on finish.
Now .NET Frame Work is installed in your PC.
______________________________________________________________ 37
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Click on Next.
______________________________________________________________ 38
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Select the path to store ARM IDE setup using Browse button shown below
then click on Next.
______________________________________________________________ 39
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Click on Next.
Click on Close.
______________________________________________________________ 40
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Now ARM IDE is installed in your PC and shortcut IDE.exe folder shown
below will automatically generate on your Desktop.
Go to control panel.
Click on change or remove program.
Find ARM IDE setup then click Remove.
Now ARM IDE is uninstalled from your PC.
______________________________________________________________ 41
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
6. Setting up hardware
6.1 Board Operation Steps:
Check LED3 status whether LED3 blink or not.(if not blink Ethernet error)
______________________________________________________________ 42
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
The window shown below will be generated. In Project name give your
project name and Project path section give path, where you want to save
your project then click on OK.
Note: - Make sure that path, which you have selected, does not contain any
space in folder name.
______________________________________________________________ 43
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
______________________________________________________________ 44
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Note: For ARM9 Target Board Select bin file as output file for program
execution.
______________________________________________________________ 45
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
______________________________________________________________ 46
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Now Editor Window, Project Window, Output Window will open automatically.
About Editor Window:- In this window you are allow to write your
program.
About Project Window:- In this window you will find Source Files, Library
Files, Command Files, Linker File, Start Up File and RTOS(if any). As shown
below you can add or remove any file by using right click on respected file.
About Output Window:- In this window you will find your output of project
after compiling it. If any error or warning in your project then you can see it
in this window.
______________________________________________________________ 47
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
For writing programs first do all the step of creating a project section.
In Editor Window write a program.
Add required files from Project Window.
Click on compile menu then click on Build or Re Build.
See the Output Window. If you find Error None then go on next step
otherwise correct the error.
______________________________________________________________ 48
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Program:
#include <stdio.h>
int main(void)
{
int i;
for (i = 1; i <= 5 ; i++)
{
printf("C: Hello world!!! %d\n", i);
}
return 0;
}
______________________________________________________________ 49
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
#include <stdio.h>
int main(void)
{
int i;
for (i = 1; i <= 5 ; i++)
{
printf("C: Hello Friends!!! %d\n", i);
}
return 0;
}
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
$ cp test.o /root/tftpboot
8. to copy test.o to target board follow this command
[root@EDUTECH/home]: tftp g r test.o 192.168.0.96
[root@EDUTECH/home]: chmod 777 test.o
9.Execute the program from target board.
[root@EDUTECH/home]: ./test.o
______________________________________________________________ 51
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
8. Demo Example
8.1 Interfacing Basic Devices with ARM9 Target using IDE
8.1.1 SEVEN SEGMENT DISPLAY INTERFACING
Objective:
To study Seven Segment Display Interface with ARM9 target board:
Study of Seven Segment board
Study of Seven Segment Display interface with AT91rm9200
Writing C program to interface Seven Segment Display
Part List:
Procedure:
______________________________________________________________ 52
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
______________________________________________________________ 53
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Program Description:
This Program will display number 1234 on seven segment display
Pin Assignment:
Connection between Seven segment board J1 connector to J12 connector of target
board
J12 Connector of Target
Board
PA0
PA1
PA2
PA3
PA4
PA5
PA6
PA17
PA18
PA19
PA20
PA21
PA22
PA23
PA24
PA25
PA26
3.3V
5.0 V
GND
J1 Connector of Seven
Segment Board
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
Digit 1
Digit 2
Digit 3
Digit 4
N.C.
N.C.
N.C.
N.C.
N.C
VCC
Ground
______________________________________________________________ 54
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
J2 Connector of Seven
Segment
Segment a
Segment b
Segment c
Segment d
Segment e
Segment f
Segment g
Segment dp
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
VCC
Ground
______________________________________________________________ 55
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Program Folder:
<EX1>
Program Listing:
#include"sevenseg.h"
#include <at91rm9200.h>
/*
void seg_init()
{
SEGMENTLINES1=0XFFFFFF;
SEGMENTLINES2=0XFFFFFF;
SEGMENTOUT1=0xFFFFFFFF;
SEGMENTOUT2=0xFFFFFFFF;
}
void seg1ment1(unsigned int a)
{
SEGMENTDATA1=0X007F;
SEGMENTSELECT1=0x00100E00;
SEGMENTDATA2=num[a];
SEGMENTSELECT2=SET(20);
}
void seg1ment2(unsigned int a)
{
SEGMENTDATA1=0X007F;
SEGMENTSELECT1=0x00100E00;
SEGMENTDATA2=num[a];
SEGMENTSELECT2=SET(11);
}
void seg1ment3(unsigned int a)
{
SEGMENTDATA1=0X007F;
SEGMENTSELECT1=0x00100E00;
SEGMENTDATA2=num[a];
SEGMENTSELECT2=SET(10);
}
void seg1ment4(unsigned int a)
{
SEGMENTDATA1=0X007F;
SEGMENTSELECT1=0x00100E00;
SEGMENTDATA2=num[a];
SEGMENTSELECT2=SET(9);
}
______________________________________________________________ 56
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
void main()
{
seg_init();
while(1){
seg1ment4(1);
delay_ms(900);
seg1ment3(2);
delay_ms(900);
seg1ment2(3);
delay_ms(900);
seg1ment1(4);
delay_ms(900);}
}
______________________________________________________________ 57
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Procedure:
START->ACCESSORIES->COMMUNICATION->HYPER
TERMINAL.
Enter The Name:
Select COM PORT:
RESET Default
Bits/sec: 115200
Apply o k
______________________________________________________________ 58
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
modem->Browse
File->
D:\IDEexamples\ex2->LCD. bin->send
Program Description:
This Program will display EDUTECH on LCD
Pin Assignment:
J11 of target board connected to J1 of LCD board
J11 Connector of
Target Board
PA0
PA1
PA2
PA3
PA4
PA5
PA6
PA17
PA18
PA19
PA20
PA21
PA22
PA23
PA24
PA25
PA26
3.3V
5.0 V
Ground
J1 Connector of
LCD/Keyboard
KB Column 0
KB Column 1
KB Column 2
KB Column 3
KB Column 4
KB Row0
KB Row 1
KB Row 2
N.C.
LCD Data Line D4
LCD Data Line D5
LCD Data Line D6
LCD Data Line D7
LCD RS Line
LCD EN line
KB Row 3
KB Row 4
N.C
VCC
Ground
J2 Connector of
LCD/Keyboard
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
VCC
Ground
______________________________________________________________ 59
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Program Folder:
<EX2>
Program Listing:
#include <at91rm9200.h>
#include "lcd.h"
AT91PS_SYS LCD=(AT91PS_SYS)AT91C_BASE_SYS;
void Edutech_Delay();
/**********************************************************************
Function Name
: void Lcddat(void)
Input
: cms,rspin
Output
: It Latches the data on the LCD pins
Description
: This function is used to latch the data on the LCD
Data lines.
**********************************************************************/
void Lcddat(char cms,char rspin)
{
long dat=cms;
dat = dat<<19;
LCD->PIOA_SODR=dat;
LCD->PIOA_CODR=~dat;
//LCD_PIN = cms;
Edutech_Delay();
if(rspin)
LCD->PIOA_SODR=LCD_RS_PIN ;
else
LCD->PIOA_CODR=LCD_RS_PIN ;
//LCD_RS_PIN = rspin;
Edutech_Delay();
LCD->PIOA_SODR=LCD_EN_PIN ;
//LCD_EN_PIN = 1;
Edutech_Delay();
//LCD_EN_PIN = 0;
LCD->PIOA_CODR=LCD_EN_PIN ;
}
/**********************************************************************
Function Name
: void LcdCommand(char lcdcommand)
Input
: lcdcommand
Output
: standard LCD command is passed.
Description
: This function is used to pass commands.
**********************************************************************/
______________________________________________________________ 60
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
void LcdCommand(char lcdcommand)
{
char dat;
dat = (lcdcommand>>4);
Lcddat(dat,RS_LOW);
Lcddat(lcdcommand,RS_LOW);
}
/**********************************************************************
Function Name
: void LcdData(char lcdcommand)
Input
: lcddata
Output
: Data is passed.
Description
: This function is used to pass Data.
**********************************************************************/
void LcdData(char lcddata)
{
char dat;
dat = (lcddata>>4);
Lcddat(dat,RS_HIGH);
Lcddat(lcddata,RS_HIGH);
}
/**********************************************************************
Function Name
: void LcdInit(void)
Input
: none
Output
: LCD gets initialized.
Description
: This function is used Initializing the LCD.
**********************************************************************/
void LcdInit()
{
Edutech_Delay();
LcdCommand(0x03);
Edutech_Delay();
LcdCommand(0x03);
Edutech_Delay();
LcdCommand(0x03);
Edutech_Delay();
LcdCommand(0x02);
Edutech_Delay();
LcdCommand(0x02);
Edutech_Delay();
LcdCommand(0x28);
Edutech_Delay();
LcdCommand(0x08);
Edutech_Delay();
LcdCommand(0x01);
Edutech_Delay();
LcdCommand(0x0C);
Edutech_Delay();
// cursor home
// display off
// display on
______________________________________________________________ 61
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
LcdCommand(0x06); // set entry mode
Edutech_Delay();
}
/**********************************************************************
Function Name
: void LcdClear(void)
Input
: none
Output
: LCD gets cleared and at the home position.
Description
: This function is used to clear the LCD.
**********************************************************************/
void LcdClear()
{
LcdCommand(0x01);
Edutech_Delay();
}
/**********************************************************************
Function Name
: void LcdCursorSet(void)
Input
: Specified Row number and Column.
Output
: LCD cursor gets set at the specified Row and
Column.
Description
: This function is used to set cursor at specified
position.
**********************************************************************/
void LcdCursorSet(char row,char column)
{
char lcdcommand=0;
switch(row)
{
case ROW1:
lcdcommand= ROWADDR1+column;
break;
case ROW2:
lcdcommand= ROWADDR2+column;
break;
case ROW3:
if (ROWADDR3==ROWADDR1)
{
lcdcommand= ROWADDR3+column;
}
else
lcdcommand= ROWADDR3+column;
break;
case ROW4:
if(ROWADDR4==ROWADDR2)
{
lcdcommand= ROWADDR4+column;
}
else
______________________________________________________________ 62
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
lcdcommand= ROWADDR4+column;
break;
}
LcdCommand(lcdcommand);
}
/**********************************************************************
Function Name
: void LcdDisplayString(char *string,char row,char
column)
Input
: String , Specified Row and Column.
Output
: String is displayed at specified Row and Column
position
Description
: This function is used to display string at
specified position.
**********************************************************************/
void LcdDisplayString(char *string,char row,char column)
{
char i=0;
LcdCursorSet(row,column);
i=column;
while(*string != '\0' && i<=COLUMNSIZE)
{
LcdData(*string++);
i++;
}
}
/**********************************************************************
Function Name
: void LcdDisplayStringCenter(char *string,char row)
Input
: String & Specified Row .
Output
: String is displayed at centre of the specified
position.
Description
: This function is used to display string at centre.
**********************************************************************/
void LcdDisplayStringCenter(char *string,char row)
{
char length,space=0,i=0;
LcdCursorSet(row,0);
length = strlen(string);
if(length < COLUMNSIZE)
{
space = (( - length)/2);
for(i=0; i<space;i++)
{
LcdData(' ');
}
while(*string != '\0')
______________________________________________________________ 63
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
{
LcdData(*string++);
//i++;
}
for(i=0; i<space;i++)
{
LcdData(' ');
}
}
else
{
while(*string != '\0')
{
LcdData(*string++);
//
i++;
}
}
}
/**********************************************************************
Function Name : void LcdDisplayNumber(char number,char row,char
column,char type)
Input
: Number, Specified Row and Column,type.
Output
: Number is displayed at the specified position.
Description
: This function is used to display number or ASCII
characters.
**********************************************************************/
void LcdDisplayNumber(char number,char row,char column,char type)
{
char nible=0;
LcdCursorSet(row,column);
if(type==DIGIT)
{
number=number+0x30;
type=ASCII;
}
else if(type==VALUE)
{
nible = ((number >> 4) & 0x0F);
if((nible >= 0x0) && (nible <= 0x9))
nible = nible +0x30;
else
nible = nible +0x37;
LcdData(nible);
nible = (number & 0x0F);
if((nible >= 0x0) && (nible <= 0x9))
nible = nible +0x30;
else
nible = nible +0x37;
type=ASCII;
number = nible;
}
______________________________________________________________ 64
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
if(type==ASCII)
{
LcdData(number);
}
}
void Edutech_Delay()
{
int i;
for(i=0;i<9000;i++){}
}
void main()
{
LCD->PIOA_OER=LCD_PIN;
LcdInit();
LcdClear();
LcdDisplayString("EDUTECH",0,0);
}
______________________________________________________________ 65
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Procedure:
Write C program in editor window of ARMIDE, build it using compile option.
To execute this program follow the steps
Connect the target board to the PC using serial cable. Use J1 connector for
serial connection.
Connect 5volt supply to J14 connector.
Set hyper terminal Parameter on windows PC in the following
way
START ->ACCESSORIES->COMMUNICATION->HYPER
TERMINAL.
RESET Default
Bits/sec: 115200
Apply ok
______________________________________________________________ 66
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
modem->Browse
File->
D:\IDEexamples\ex3->relay. bin->send
Program Description:
This Program will make relay on/off for specific time.
Pin Assignment:
Relay ask J1 connector to J11 of Target board
J11 Connector of Target
Board
PA0
PA1
PA2
PA3
PA4
PA5
PA6
PA17
PA18
PA19
PA20
PA21
PA22
PA23
PA24
PA25
PA26
3.3V
5.0 V
GND
J1 Connector of Relay
N.C.
N.C.
N.C.
Mechanical Relay
Mechanical Relay
Mechanical Relay
Mechanical Relay
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
VCC
Ground
1
2
3
4
______________________________________________________________ 67
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Program Folder:
<EX3>
Program Listing:
#include <at91rm9200.h>
AT91PS_SYS Relay=(AT91PS_SYS)AT91C_BASE_SYS;
//#include "new.h"
//#define set(x) (1<<x)
//#define clr(x) (0<<x)
void delay_ms(unsigned long ms);
int main (void)
{
Relay->PIOA_PER=0XF00FF;
Relay->PIOA_OER = 0xFffff;//set(1); // output enable reg
while(1)
{
Relay->PIOA_SODR = 0xF00ff;//set(1); //set high on PA1
delay_ms(100000); // delay function
Relay->PIOA_CODR = 0xF00ff;//set(1); // Set low on PA1
delay_ms(100000);
}
}
void delay_ms(unsigned long ms)
{
while(ms)
{
--ms;
}
}
______________________________________________________________ 68
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Procedure:
Write C program in editor window of ARMIDE, build it using compile option.
To execute this program follow the steps
1. Connect the target board to the PC using serial cable. Use J1
connector for serial connection.
2. Connect 5volt supply to J14 connector.
3. Set hyper terminal Parameter on windows PC in the following
way START ->ACCESSORIES->COMMUNICATION->HYPER
TERMINAL.
Enter The Name:
Select COM PORT:
RESET Default
Bits/sec: 115200
Apply ok
It opens hyper terminal window
______________________________________________________________ 69
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
File->
Program Description:
This Program will move Stepper Motor in clockwise and anticlockwise
direction for given period.
Pin Assignment:
Stepper Motors J1 connector to J12 connector of Target board
J12 Connector of Target
Board
PB0
PB1
PB2
PB3
PB4
PB5
PB6
PB7
PB8
PB9
PB10
PB11
PB20
PB21
PB22
PB23
PB24
3.3V
5.0V
GND
J1 Connector of Stepper
Motor
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
L4 (Green)
N.C.
L3 (Blue)
N.C.
L2 (Orange)
N.C.
L1 (Red)
N.C.
N.C.
VCC
Ground
______________________________________________________________ 70
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Program Folder:
<EX4>
Program Listing:
//-----------------------------------------------------------------//
STEPPERMOTR.c
//-----------------------------------------------------------------//
#include <at91rm9200.h>
AT91PS_SYS SM=(AT91PS_SYS)AT91C_BASE_SYS;
void
{
Stepper_Init()
SM->PIOB_PER=0XFFFFFFFF;
SM->PIOB_OER=0XFFFFFFFF;
}
/********************************************************************
Function Name
: void rotate_clockwise(unsigned int d)
Input
: delay parameter d.
return type
: None.
Description
: This function is used to step the stepper motor
in the clockwise direction.
********************************************************************/
void rotate_anticlockwise(unsigned int d,unsigned int rotate)
{
int sm[4]= {0x01100000,0x00500000,0x00400400,0x01000400};
int i;
while(rotate!= 0)
{
for(i=0;i<4;i++)
{
SM->PIOB_SODR= sm[i];
Delay_ms(d);
SM->PIOB_CODR = sm[i];
}
rotate--;
}
}
/********************************************************************
Function Name
: void rotate_anticlockwise(unsigned int d)
Input
: delay parameter d.
return type
: None.
Description
: This function is used to step the stepper motor
in the Anti - clockwise direction.
********************************************************************/
______________________________________________________________ 71
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
void rotate_clockwise(unsigned int d,unsigned int rotate)
{
int sm[4]= {0x01100000,0x00500000,0x00400400,0x01000400};
int i;
while(rotate!=0)
{
for(i=3;i>=0;i--)
{
SM->PIOB_SODR= sm[i];
Delay_ms(d);
SM->PIOB_CODR = sm[i];
}
rotate--;
}
}
Delay_ms(int ms)
{
while(ms)
{
--ms;
}
}
void main()
{
Stepper_Init();
while(1)
{
rotate_clockwise(5000,1000);
rotate_anticlockwise(5000,1000);
}
}
______________________________________________________________ 72
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Procedure:
Write C program in editor window of ARMIDE, build it using compile
option.
To execute this program follow the steps
1. Connect the target board to the PC using serial cable. Use J1
connector for serial connection.
2. Connect 5volt supply to J14 connector.
______________________________________________________________ 73
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
modem->Browse
File->
Program Description:
This Program will detect the key press and display column/row wise hex value
on LCD accordingly.
Pin Assignment:
J11 of target board connected to J1 of LCD/Keyboard board
J11 Connector of
Target Board
PA0
PA1
PA2
PA3
PA4
PA5
PA6
PA17
PA18
PA19
PA20
PA21
PA22
PA23
PA24
PA25
PA26
3.3V
5.0 V
Ground
J1 Connector of
LCD/Keyboard
KB Column 0
KB Column 1
KB Column 2
KB Column 3
KB Column 4
KB Row0
KB Row 1
KB Row 2
N.C.
LCD Data Line D4
LCD Data Line D5
LCD Data Line D6
LCD Data Line D7
LCD RS Line
LCD EN line
KB Row 3
KB Row 4
N.C
VCC
Ground
J2 Connector of
LCD/Keyboard
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
N.C.
VCC
Ground
______________________________________________________________ 74
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Program Folder:
<EX5>
Program Listing:
#include<at91rm9200.h>
#include<lcd_Arm9.h>
#include "matrix.h"
#define SET(X) (1<<X)
void delay_ms(unsigned int ms)
{
while(ms)
{
while(ms)
--ms;
}
}
void Edutech_MatrixKbrd_init()
{
KB->PIOA_PER|=0XFFFFFFFF;
KB->PIOA_OER|=0XFFFFFFE0;
PORTA_CLEAR|=0XFFFFFFE0;
}
//SELECT LINES
//ROW AS OUTPUT
//CLEAR ALL ROWS
/********************************************************************
Function Name
: Edutech_280X_KeyDetect(void)
Input
: None
Output
: value of the detected key.
Description
: This function is used to detecte key which has
been pressed.
********************************************************************/
char Edutech_KeyDetect(void)
{
unsigned int data;
PORTA_CLEAR|= ROWPINS_PORTA;
row = Edutech_FindRow();
col = Edutech_FindCol();
data= col+(row*10);
if((row >=0 && row <=4) && (col >=0 && col <=4))
{
return (data);
}
else
return (data);
}
______________________________________________________________ 75
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
/********************************************************************
Function Name
: Edutech_280X_FindCol(void)
Input
: None
Output
: value of the Column detected.
Description
: This function is used to detect the Column of key
pressed.
********************************************************************/
int Edutech_FindCol(void)
{
long int i;
KB->PMC_PCER=0X1F;
i=PORTA_DATA_READ;
i = (i & MCOLUMNALL);
switch(i)
{
case
MCOLUMN0:
return(0);
case
MCOLUMN1:
return(1);
case
MCOLUMN2:
return(2);
case
MCOLUMN3:
return(3);
case
MCOLUMN4:
return(4);
}
return(-1);
}
/********************************************************************
Function Name
: Edutech_280X_FindRow(void)
Input
: None
Output
: value of the Row detected.
Description
: This function is used to detect the Row of key
pressed.
********************************************************************/
int Edutech_FindRow(void)
{
int i;
long int j=0;
for(i=0;i<5;i++)
{
PORTA_SET|= ROWPINS_PORTA;
switch(i)
{
case 0:
PORTA_CLEAR=SET(5);
______________________________________________________________ 76
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
case 1:
case 2:
case 3:
case 4:
break;
PORTA_CLEAR=SET(6);
break;
PORTA_CLEAR=SET(17);
break;
PORTA_CLEAR=SET(25);
break;
PORTA_CLEAR=SET(26);
break;
}
KB->PMC_PCER=0XFFFFFFE0;
j= PORTA_DATA_READ;
if((j & MCOLUMNALL) != MCOLUMNALL)
{
PORTA_CLEAR = ROWPINS_PORTA;
return(i);
}
}
PORTA_CLEAR = ROWPINS_PORTA;
return(-1);
}
/********************************************************************
Function Name
: Edutech_280X_KeyPressed()
Input
: None
Output
: key pressed or not.
Description
: This function is used to know key pressed or not.
********************************************************************/
int Edutech_KeyPressed(void)
{
long int i=0;
PORTA_CLEAR|= 0X06020060;
KB->PMC_PCER|=0X1F;
i = PORTA_DATA_READ;
if((i & MCOLUMNALL) != MCOLUMNALL)
{
Edutech_Delay(100000);
if((i & MCOLUMNALL) != MCOLUMNALL)
{
return(1);
}
}
else
{
return(0);
}
return(-1);
}
______________________________________________________________ 77
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
/********************************************************************
Function Name
: Edutech_280X_AllKeyOpen()
Input
: None
Output
: All key opened or not.
Description
: This function is used to know all key opened or
not.
********************************************************************/
int Edutech_AllKeyOpen(void)
{
unsigned int i=0;
KB->PMC_PCER=0X1F;
i = PORTA_DATA_READ;
if((i & MCOLUMNALL) == MCOLUMNALL)
{
return(1);
}
else
{
return(0);
}
}
int col,data,row;
void main()
{
unsigned int data=0;
KB->PIOA_OER|=LCD_PIN;
Edutech_MatrixKbrd_init();
LcdInit();
LcdClear();
while(1)
{
KB->PIOA_CODR|=0X06020060;
while(Edutech_KeyPressed())
{
data=Edutech_KeyDetect();
row=data/10;
col=data%10;
LcdCommand(0x80);
LcdData(row+48);
LcdData(col+48);
while(!( Edutech_AllKeyOpen()))
{
}
delay_ms(100000);
}
}
}
______________________________________________________________ 78
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Procedure:
Write C program in editor window of ARMIDE, build it using compile
option.
To execute this program follow the steps
1) Connect the target board to the PC using serial cable. Use J1
connector for serial connection.
2) Connect 5volt supply to J14 connector.
______________________________________________________________ 79
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
modem->Browse
File->
Program Description:
This Program will display alphabets abcde.
Pin Assignment:
GRAPHIC LCD J2 CONNECTOR TO J11 CONNECTOR OF TARGET BOARD
J2 Connector of Graphic
LCD
Vss
Vdd
Vo
/RD
/WR
A0
DB0
DB1
DB2
DB3
DB4
DB5
DB6
DB7
/CS
/RES
VEE
NC
NC
Vss
______________________________________________________________ 80
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Program Folder:
<EX6>
Program Listing:
#include<at91rm9200.h>
#include "glcd.h"
//#include "edulogo.inc"
#define SET(x) (1<<x)
#define CLR(x) (0<<x)
AT91PS_SYS GLCD=(AT91PS_SYS)AT91C_BASE_SYS;
void output_high(int data)
{
GLCD->PIOA_SODR=data;
}
void glcd_init(void)
{
GLCD->PIOA_PER=GLCD_PIN;
delay_ms(200);
GLCD->PIOA_OER=GLCD_PIN;
delay_ms(200);
output_low(GLCD_RST);
delay_ms(200);
delay_ms(200);
output_high(GLCD_RST);
delay_ms(200);
delay_ms(200);
GLCD->PIOA_SODR=GLCD_PIN;
//System Set
glcd_cmd(0x40);
glcd_dat(0x30);
glcd_dat(0x87);
glcd_dat(0x07);
glcd_dat(0x27);
glcd_dat(0x2f);
glcd_dat(0xef);
glcd_dat(0x28);
glcd_dat(0x00);
//Scroll
glcd_cmd(0x44);
glcd_dat(0x00);
glcd_dat(0x00);
glcd_dat(0xf0);
glcd_dat(0xb0);
glcd_dat(0x04);
glcd_dat(0xf0);
glcd_dat(0x00);
______________________________________________________________ 81
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
glcd_dat(0x00);
glcd_dat(0x00);
glcd_dat(0x00);
glcd_cmd(0x5d);
glcd_dat(0x07);
glcd_dat(0x07);
glcd_cmd(0x4c);
glcd_cmd(0x5a);
glcd_dat(0x00);
glcd_cmd(0x5b);
glcd_dat(0x00);
glcd_cmd(0x58);
glcd_dat(0x16);
glcd_clr();
}
void output_low(int data)
{
GLCD->PIOA_CODR=data;
}
void glcd_cmd(unsigned long int cmd)
{
output_high(GLCD_A0);
//a0 high
output_high(GLCD_A0);
//a0 high
cmd=cmd<<(19);
// Data shift
GLCD->PIOA_SODR=cmd;
GLCD->PIOA_CODR=((~cmd)&GLCD_DATAPIN);
output_low(GLCD_CS);
//CS CLEAR
output_low(GLCD_WR);
delay_ms(200);
output_high(GLCD_WR);
output_high(GLCD_CS);
GLCD->PIOA_SODR=GLCD_PIN;
delay_ms(200);
}
void glcd_dat(unsigned long int dat)
{
output_low(GLCD_A0);
output_low(GLCD_A0);
dat=dat<<(19);
GLCD->PIOA_SODR=dat;
GLCD->PIOA_CODR=((~dat)&GLCD_DATAPIN);
output_low(GLCD_CS);
output_low(GLCD_WR);
delay_ms(200);
output_high(GLCD_WR);
output_high(GLCD_CS);
______________________________________________________________ 82
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
GLCD->PIOA_SODR=GLCD_PIN;
delay_ms(200);
}
void glcd_clr(void)
{
int j;
glcd_cmd(0x46);
glcd_dat(0x00);
glcd_dat(0x00);
glcd_cmd(0x42);
for(j=0;j<1200;j++)
{
glcd_dat(0x20);
}
glcd_cmd(0x46);
glcd_dat(0xb0);
glcd_dat(0x04);
glcd_cmd(0x42);
for(j=0;j<9600;j++)
{
glcd_dat(0x00);
}
delay_ms(10);
glcd_cmd(0x59);
delay_ms(50);
}
void setaddr(unsigned int addrl,unsigned int addrh)
{
glcd_cmd(0x46);
glcd_dat(addrl);
glcd_dat(addrh);
}
void display(char *str)
{
glcd_cmd(0x42);
while(*str)
{
glcd_dat(*str);
str++;
}
}
/*void graphic(int row,int col,int low,int high)
{
int a,b;
glcd_cmd(0x4f);
______________________________________________________________ 83
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
for(a=0;a<col;a++)
{
setaddr(low,high);
glcd_cmd(0x42);
for(b=0;b<row;b++)
{
glcd_dat(data[a][b]);
}
low++;
}
}*/
delay_ms(int ms)
{
while(ms){--ms;}
}
void main()
{
glcd_init();
//while(1)
{
setaddr(0x00,0x00);
glcd_cmd(0x42);
glcd_dat(0x41);
display("ABCDEFGH");
}
}
______________________________________________________________ 84
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Procedure:
write C program in editor window of ARMIDE, build it using compile
option.
To execute this program follow the steps
1. Connect the target board to the PC using serial cable. Use J1
connector for serial connection.
2. Connect 5volt supply to J14 connector.
3. Set hyper terminal Parameter on windows PC in the following
way
______________________________________________________________ 85
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
modem->Browse
File->
Program Description:
If UART communication is successful, it will display "UART Init." On hyper terminal
window.
Program Folder:
<EX7>
Program Listing:
#include <at91rm9200.h>
//#include "NEW.H"
#define
AT91C_US_ASYNC_MODE
(AT91C_US_USMODE_NORMAL
+
AT91C_US_NBSTOP_1_BIT + AT91C_US_PAR_NONE + AT91C_US_CHRL_8_BITS +
AT91C_US_CLKS_CLOCK)
#define AT91C_MASTER_CLOCK 60000000
char GetChar[10],i=0;
//#define
AT91C_US_ASYNC_MODE
(AT91C_US_USMODE_NORMAL
+
AT91C_US_NBSTOP_1_BIT + AT91C_US_PAR_NONE + AT91C_US_CHRL_8_BITS +
AT91C_US_CLKS_CLOCK)
static void Enable_Debug_USART(AT91PS_DBGU pUSART) {
AT91PS_PDC pPDC = (AT91PS_PDC)&(pUSART->DBGU_RPR);
AT91PS_PIO pPio = (AT91PS_PIO)AT91C_BASE_PIOA;
pPio->PIO_ASR =
((unsigned)AT91C_PA31_DTXD)
((unsigned)AT91C_PA30_DRXD);
pPio->PIO_BSR = 0;
pPio->PIO_PDR =
((unsigned)AT91C_PA31_DTXD)
((unsigned)AT91C_PA30_DRXD);
pUSART->DBGU_CR
=AT91C_US_RSTRX
AT91C_US_RXDIS | AT91C_US_TXDIS;
pUSART->DBGU_BRGR
|
|
AT91C_US_RSTTX
|
=
______________________________________________________________ 86
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
((((AT91C_MASTER_CLOCK*10)/(9600*16))+5)/10);
pUSART->DBGU_IDR = 0;
pUSART->DBGU_IER = AT91C_US_RXRDY;
pPDC->PDC_PTCR = AT91C_PDC_RXTDIS;
pPDC->PDC_PTCR = AT91C_PDC_TXTDIS;
pPDC->PDC_TNPR = 0;
pPDC->PDC_TNCR = 0;
pPDC->PDC_RNPR = 0;
pPDC->PDC_RNCR = 0;
pPDC->PDC_TPR = 0;
pPDC->PDC_TCR = 0;
pPDC->PDC_RPR = 0;
pPDC->PDC_RCR = 0;
pPDC->PDC_PTCR = AT91C_PDC_RXTEN;
pPDC->PDC_PTCR = AT91C_PDC_TXTEN;
pUSART->DBGU_MR = AT91C_US_ASYNC_MODE;
pUSART->DBGU_CR = AT91C_US_TXEN;
pUSART->DBGU_CR = AT91C_US_RXEN;
}
void SendData(AT91PS_DBGU pUSART,char transmit)
{
while (!(pUSART->DBGU_CSR & AT91C_US_TXRDY));
{
pUSART->DBGU_THR = (transmit & 0x1FF);
}
}
char GetCh(AT91PS_DBGU pUSART)
{
while(!(pUSART->DBGU_CSR & AT91C_US_RXRDY));
{
GetChar[i++] = (pUSART->DBGU_RHR & 0x1FF);
return(1);
}
//
else
return(0);
}
void DebugPrintf(char *buffer)
{
while(*buffer != '\0')
{
SendData(((AT91PS_DBGU)AT91C_BASE_DBGU),*buffer++);
}
}
void main(void)
{
char i=0;
while(1)
{
DebugPrintf("UART Init.");
//i++;
______________________________________________________________ 87
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
}
/*asm(".equ test, 0x10F80000");
//char *ptr;
//ptr=&test;
DebugPrintf("shailesh");
asm("ldr
r0,=test");
//asm("MOV r0,&ptr");
asm("mov lr, pc");
asm("BX r0");*/
/*while(i<10)
{
if(GetCh(((AT91PS_DBGU)AT91C_BASE_DBGU)))
{
}
}
for(i=0;i<10;i++)
{
SendData(((AT91PS_DBGU)AT91C_BASE_DBGU),GetChar[i]);
if(GetChar[i] == 0x0D)*/
SendData(((AT91PS_DBGU)AT91C_BASE_DBGU),'s');
//}
}
______________________________________________________________ 88
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
8.2 Interfacing Basic OS based linux programs with ARM9 Target with
linux
Lab 1
Objective:
To observe the booting process and practice basic commands using ARM9 target
board.
Steps:
1. Connect the target board to the PC using the serial cable. Use the J1
connector for the serial connection.
2. Connect the supplied Ethernet cable to the J13 connector on the target and
the PC
3. Open the hyper terminal OR minicom and make the settings as mentioned:
Baud Rate = 115200, data bit 8, parity = none, stop bit = 1
4. Power on the target board
5. Observe on the screen the booting process. If you do not see the boot
process, check the settings one again as mentioned above and apply reset to
the target.
6. Login as 'root' on the terminal
7. Check the following commands using the following the steps:
[root@EDUTECH]cd ..
[root@EDUTECH]ls
[root@EDUTECH]cd /home
[root@EDUTECH/home]ls
[root@EDUTECH/home]cd ..
[root@EDUTECH/]
______________________________________________________________ 89
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab 2
Objective:
To write a simple program to display Hello World using ARM9 target board, build it,
and execute it using the target board.
Program:
#include <stdio.h>
int main(void)
{
int i;
for (i = 1; i <= 5 ; i++)
{
printf("C: Hello world!!! %d\n", i);
}
return 0;
}
Steps:
To execute:
______________________________________________________________ 90
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
To modify:
______________________________________________________________ 91
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab 3
Objective:
To write a simple program to create process using ARM9 target board, build it, and
execute it using the target board.
Program:
#include <unistd.h>
#include <sys/types.h>
#include <errno.h>
#include <stdio.h>
#include <sys/wait.h>
#include <stdlib.h>
/* this program create a process*/
void child_process()
{
int i;
for (i=0; i < 5; i++)
{
printf("I am child process!\n");
}
}
int main()
{
pid_t childpid; /* variable to store the child's pid */
int retval;
/* child process: user-provided return code */
int status;
/* parent process: child's exit status */
childpid = fork();
if (childpid >= 0) /* fork succeeded */
{
if (childpid == 0) /* fork() returns 0 to the child process
*/
{
printf("CHILD: I am the child process!\n");
printf("CHILD: Here's my PID: %d\n", getpid());
printf("CHILD: My parent's PID is: %d\n", getppid());
printf("CHILD: The value of my copy of childpid is:
%d\n", childpid);
child_process();
printf("CHILD: Sleeping for 1 second...\n");
sleep(1);
printf("CHILD: Enter an exit value (0 to 255): ");
scanf(" %d", &retval);
printf("CHILD: Goodbye!\n");
exit(retval);
}
else /* fork() returns new pid to the parent process */
______________________________________________________________ 92
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
{
printf("PARENT: I am the parent process!\n");
printf("PARENT: Here's my PID: %d\n", getpid());
printf("PARENT: The value of my copy of childpid is
%d\n", childpid);
printf("PARENT: I will now wait for my child to
exit.\n");
wait(&status); /* wait for child to exit, and store its
status */
printf("PARENT: Child's exit code is: %d\n",
WEXITSTATUS(status));
printf("PARENT: Goodbye!\n");
exit(0); /* parent exits */
}
}
else /* fork returns -1 on failure */
{
perror("fork"); /* display error message */
exit(0);
}
}
Steps:
To execute:
to execute program from ARM9 target board go to /home/Example directory
by this command
[root@EDUTECH~]:cd /home/example
now execute lab3 by this command
[root@EDUTECH~]:./lab3
______________________________________________________________ 93
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
To modify:
$ cd /home/lab/lab3
Using the Editor modify the lab3.c program
$ vi lab3.c
______________________________________________________________ 94
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab 4
Objective:
To write a simple program to create clone of process, build it, and execute it using
the target board.
Program:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sched.h>
#include <sys/wait.h>
#define GOT1
(1 << 1)
#define GOT2
(1 << 2)
#define GOT3
(1 << 3)
#define ALLGOT
(GOT1|GOT2|GOT3)
void child_handler(int sig)
{
printf("I got a SIGCHLD\n");
}
int clone_main(void *arg)
{
unsigned long input = (unsigned long)arg;
int secs = input * 4;
printf("Clone got %lu, sleeping for %i secs\n", input, secs);
sleep(secs);
return input + 20;
}
int main(void)
{
int clone1, clone2, clone3;
char clone1_stack[8192], clone2_stack[8192],
clone3_stack[8192];
int status, nostatus, result, wpid;
//signal(SIGCHLD, child_handler);
if ((clone1 = clone(clone_main, clone1_stack, 0, (void*)1)) ==
-1) {
perror("Clone 1 failed");
exit(-1);
}
if ((clone2 = clone(clone_main, clone2_stack, 0, (void*)2)) ==
-1) {
perror("Clone 2 failed");
exit(-2);
}
if ((clone3 = clone(clone_main, clone3_stack, 0, (void*)3)) ==
-1) {
______________________________________________________________ 95
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
perror("Clone 3 failed");
exit(-3);
}
sleep(1);
printf("Parent: waiting for the clones to die.\n");
nostatus = status = 0;
while (1) {
if ((wpid = waitpid(clone1, &result, WNOHANG|__WCLONE))
== -1)
nostatus |= GOT1;
if (wpid == clone1) {
status |= GOT1;
printf("Clone1 gave back %i\n",
WEXITSTATUS(result));
}
if ((wpid = waitpid(clone2, &result, WNOHANG|__WCLONE))
== -1)
nostatus |= GOT2;
if (wpid == clone2) {
status |= GOT2;
printf("Clone2 gave back %i\n",
WEXITSTATUS(result));
}
if ((wpid = waitpid(clone3, &result, WNOHANG|__WCLONE))
== -1)
nostatus |= GOT3;
if (wpid == clone3) {
status |= GOT3;
printf("Clone3 gave back %i\n",
WEXITSTATUS(result));
}
if (status == ALLGOT || nostatus == ALLGOT)
break;
}
if (status == ALLGOT) {
printf("Clones exited.\nGoodbye.\n");
return EXIT_SUCCESS;
} else {
perror("Waiting for clones failed");
return EXIT_FAILURE;
}
}
______________________________________________________________ 96
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Steps:
To execute:
to execute program from ARM9 target board go to /home/Example directory
by this command
[root@EDUTECH~]:cd /home/example
now execute lab4 by this command
[root@EDUTECH~]:./lab4
To modify:
______________________________________________________________ 97
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab 5
Objective:
To write a simple program to create thread, build it, and execute it using the target
board.
Program:
#include <stdio.h>
#include <string.h>
#include <pthread.h>
#define
NUM_THREADS 5
/* this program create the thread*/
void *PrintHello(void * threadid)
{
int tid;
tid = (int)threadid;
printf("Hello World! It's me, thread #%d!\n", tid);
pthread_exit(NULL);
}
int main(int argc, char *argv[])
{
pthread_t threads[NUM_THREADS]; //define the thread variable
int rc,i;
for(i=0;i<=NUM_THREADS;i++)
{
printf("In main: creating thread %d\n", i);
rc = pthread_create(&threads[i], NULL, PrintHello, (void *)i);
if (rc)
{
printf("ERROR; return code from pthread_create() is %d\n", rc);
exit(-1);
}
}
pthread_exit(NULL);
}
______________________________________________________________ 98
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Steps:
To execute:
to execute program from ARM9 target board go to /home/Example directory
by this command
[root@EDUTECH~]:cd /home/example
now execute lab5 by this command
[root@EDUTECH~]:./lab5
To modify:
1. Start the Lab5 sesssion in linux host PC.
$ cd /home/lab/lab5
2. Using the Editor modify the lab5.c program
$ vi lab5.c
3. Build the program.
$ make
4.
______________________________________________________________ 99
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab 6
Objective:
To write a simple program to create thread and pass the argument , build it, and
execute it using the target board.
Program:
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
static pthread_key_t str_key;
static pthread_once_t str_alloc_key_once = PTHREAD_ONCE_INIT;
static void str_alloc_key(void);
static void str_alloc_destroy_accu(void * accu);
char * str_accumulate(const char * s)
{
char * accu;
pthread_once(&str_alloc_key_once, str_alloc_key);
accu = (char *) pthread_getspecific(str_key);
if (accu == NULL) {
accu = malloc(1024);
if (accu == NULL) return NULL;
accu[0] = 0;
pthread_setspecific(str_key, (void *) accu);
printf("Thread %lx: allocating buffer at %p\n", pthread_self(),
accu);
}
strcat(accu, s);
return accu;
}
static void str_alloc_key(void)
{
pthread_key_create(&str_key, str_alloc_destroy_accu);
printf("Thread %lx: allocated key %d\n", pthread_self(), str_key);
}
static void str_alloc_destroy_accu(void * accu)
{
printf("Thread %lx: freeing buffer at %p\n", pthread_self(), accu);
free(accu);
}
void * process(void * arg)
{
char * res;
______________________________________________________________ 100
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
res = str_accumulate("Result of ");
res = str_accumulate((char *) arg);
res = str_accumulate(" thread");
printf("Thread %lx: \"%s\"\n", pthread_self(), res);
return NULL;
}
int main(int argc, char ** argv)
{
char * res;
pthread_t th1, th2;
res = str_accumulate("Result of ");
pthread_create(&th1, NULL, process, (void *) "first");
pthread_create(&th2, NULL, process, (void *) "second");
str_accumulate("initial thread");
printf("Thread %lx: \"%s\"\n", pthread_self(), res);
pthread_join(th1, NULL);
pthread_join(th2, NULL);
exit(0);
}
res =
Steps:
To execute:
[root@EDUTECH~]:cd /home/example
[root@EDUTECH~]:./lab6
______________________________________________________________ 101
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
To modify:
______________________________________________________________ 102
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab 7
Objective:
To write a simple program of synchronization between thread using conditional
variable build it, and execute it using the target board.
Program:
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
pthread_mutex_t count_mutex
= PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t condition_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t condition_cond = PTHREAD_COND_INITIALIZER;
void *functionCount1();
void *functionCount2();
int count = 0;
#define COUNT_DONE 10
#define COUNT_HALT1 3
#define COUNT_HALT2 6
main()
{
pthread_t thread1, thread2;
pthread_create( &thread1, NULL, &functionCount1, NULL);
pthread_create( &thread2, NULL, &functionCount2, NULL);
pthread_join( thread1, NULL);
pthread_join( thread2, NULL);
exit(0);
}
void *functionCount1()
{
for(;;)
{
pthread_mutex_lock( &condition_mutex );
while( count >= COUNT_HALT1 && count <= COUNT_HALT2 )
{
pthread_cond_wait( &condition_cond, &condition_mutex );
}
pthread_mutex_unlock( &condition_mutex );
pthread_mutex_lock( &count_mutex );
count++;
printf("Counter value functionCount1: %d\n",count);
pthread_mutex_unlock( &count_mutex );
if(count >= COUNT_DONE) return(NULL);
}
}
void *functionCount2()
{
for(;;)
{
pthread_mutex_lock( &condition_mutex );
if( count < COUNT_HALT1 || count > COUNT_HALT2 )
{
pthread_cond_signal( &condition_cond );
______________________________________________________________ 103
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
}
pthread_mutex_unlock( &condition_mutex );
pthread_mutex_lock( &count_mutex );
count++;
printf("Counter value functionCount2: %d\n",count);
pthread_mutex_unlock( &count_mutex );
if(count >= COUNT_DONE) return(NULL);
}
}
Steps:
To execute:
[root@EDUTECH~]:./lab7
To modify:
______________________________________________________________ 104
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab 8
Objective:
To write a simple program of syncronization between thread using mutex build it,
and execute it using the target board.
Program:
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
void *functionC();
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
int counter = 0;
main()
{
int rc1, rc2;
pthread_t thread1, thread2;
/* Create independent threads each of which will execute functionC
*/
if( (rc1=pthread_create( &thread1, NULL, &functionC, NULL)) )
{
printf("Thread creation failed: %d\n", rc1);
}
if( (rc2=pthread_create( &thread2, NULL, &functionC, NULL)) )
{
printf("Thread creation failed: %d\n", rc2);
}
/* Wait till threads are complete before main continues. Unless we
*/
/* wait we run the risk of executing an exit which will terminate
*/
/* the process and all threads before the threads have completed.
*/
pthread_join( thread1, NULL);
pthread_join( thread2, NULL);
exit(0);
}
void *functionC()
{
pthread_mutex_lock( &mutex1 );
counter++;
printf("Counter value: %d\n",counter);
pthread_mutex_unlock( &mutex1 );
}
______________________________________________________________ 105
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Steps:
To execute:
To modify:
______________________________________________________________ 106
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab 9
Objective:
To write a simple program of Interporcess communication between two process
using pipe build it, and execute it using the target board.
Program:
#include <unistd.h>
#include <sys/types.h>
#include <errno.h>
#include <stdio.h>
#include <sys/wait.h>
#include <stdlib.h>
int main()
{
int n; /* store the number of characters read */
char buf[100]; /* store the characters read */
int fd[2];
printf("Starting the pipe.c program\n\n");
printf("Create the pipe\n\n");
pipe(fd); /* fd[0] read; fd[1] write */
printf("Create the child process using fork\n");
if ( fork() == 0 ) /* create child, test return value */
{
close(fd[1]); /* close write end - not needed in this
example */
printf("child is running...\n");
printf("about to read from the pipe\n");
n = read( fd[0], buf, 100); /* child reads from pipe
*/
printf("after reading from the pipe\n");
printf("the value of n is: %d\n",n);
printf("the value in the buffer is: %s\n\n", buf);
}
else /* parent*/
{
close(fd[0]); /* close read end - not needed for this
example */
printf("parent is running...\n");
printf("about to write to the pipe\n");
write( fd[1], "Writing to pipe\n", 16); /* parent writes to
pipe */
printf("after writing to the pipe\n\n");
}
printf("Ending the c program\n");
exit(0);
}
______________________________________________________________ 107
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Steps:
To execute:
To modify:
______________________________________________________________ 108
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab 10
Objective:
To write a simple program of Interporcess communication between two process
using signal build it, and execute it using the target board.
Program:
#include <unistd.h>
#include <sys/types.h>
#include <errno.h>
#include <stdio.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <signal.h>
void sighup(); /* routines child will call upon sigtrap */
void sigint();
void sigquit();
int main()
{
int pid;
/* get child process */
if ((pid = fork()) < 0)
{
perror("fork");
exit(1);
}
if (pid == 0)
{ /* child */
signal(SIGHUP,sighup); /* set function calls */
signal(SIGINT,sigint);
signal(SIGQUIT, sigquit);
for(;;); /* loop for ever */
}
else /* parent */
{ /* pid hold id of child */
printf("\nPARENT: sending SIGHUP\n\n");
kill(pid,SIGHUP);
sleep(3); /* pause for 3 secs */
printf("\nPARENT: sending SIGINT\n\n");
kill(pid,SIGINT);
sleep(3); /* pause for 3 secs */
printf("\nPARENT: sending SIGQUIT\n\n");
kill(pid,SIGQUIT);
sleep(3);
}
return(0);
}
______________________________________________________________ 109
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
void sighup()
{
signal(SIGHUP,sighup); /* reset signal */
printf("CHILD: I have received a SIGHUP\n");
}
void sigint()
{
signal(SIGINT,sigint); /* reset signal */
printf("CHILD: I have received a SIGINT\n");
}
void sigquit()
{
printf("My DADDY has Killed me!!!\n");
exit(0);
}
Steps:
To execute:
______________________________________________________________ 110
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
To modify:
______________________________________________________________ 111
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab 11
Objective:
To write a simple program of Interporcess communication between two process
using semaphore build it, and execute it using the target board.
Program:
#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
union semun {
int val;
struct semid_ds *buf;
ushort *array;
}
main()
{ int i,j;
int pid;
int semid; /* semid of semaphore set */
key_t key = 1234; /* key to pass to semget() */
int semflg = IPC_CREAT | 0666; /* semflg to pass to semget() */
int nsems = 1; /* nsems to pass to semget() */
int nsops; /* number of operations to do */
struct sembuf *sops = (struct sembuf *) malloc(2*sizeof(struct
sembuf));
/* ptr to operations to perform */
/* set up semaphore */
if ((semid = semget(key, nsems, semflg)) == -1) {
perror("semget: semget failed");
exit(1);
} else
(void) fprintf(stderr, "semget: semget succeeded: semid =\
%d\n", semid);
/* get child process */
if ((pid = fork()) < 0) {
perror("fork");
exit(1);
}
if (pid == 0)
{ /* child */
i = 0;
while (i < 1) {/* allow for 3 semaphore sets */
nsops = 2;
/* wait for semaphore to reach zero */
sops[0].sem_num = 0; /* We only use one track */
sops[0].sem_op = 0; /* wait for semaphore flag to become zero
*/
sops[0].sem_flg = SEM_UNDO; /* take off semaphore asynchronous
______________________________________________________________ 112
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
*/
sops[1].sem_num = 0;
sops[1].sem_op = 1; /* increment semaphore -- take control of
track */
sops[1].sem_flg = SEM_UNDO | IPC_NOWAIT; /* take off semaphore
*/
/* Recap the call to be made. */
(void) fprintf(stderr,"\nsemop:Child Calling semop(%d,
&sops, %d) with:", semid, nsops);
for (j = 0; j < nsops; j++)
{
(void) fprintf(stderr, "\n\tsops[%d].sem_num = %d, ", j,
sops[j].sem_num);
(void) fprintf(stderr, "sem_op = %d, ", sops[j].sem_op);
(void) fprintf(stderr, "sem_flg = %#o\n", sops[j].sem_flg);
}
/* Make the semop() call and report the results. */
if ((j = semop(semid, sops, nsops)) == -1) {
perror("semop: semop failed");
}
else
{
(void) fprintf(stderr, "\tsemop: semop returned %d\n",
j);
(void) fprintf(stderr, "\n\nChild Process Taking Control
of Track: %d/3 times\n", i+1);
sleep(5); /* DO Nothing for 5 seconds */
nsops = 1;
/* wait for semaphore to reach zero */
sops[0].sem_num = 0;
sops[0].sem_op = -1; /* Give UP COntrol of track */
sops[0].sem_flg = SEM_UNDO | IPC_NOWAIT; /* take
off semaphore, asynchronous */
if ((j = semop(semid, sops,
nsops)) == -1) {
perror("semop: semop failed");
}
else
(void) fprintf(stderr, "Child Process Giving up
Control of Track: %d/3 times\n", i+1);
sleep(5); /* halt process to allow parent to
catch semaphor change first */
}
++i;
}
}
else /* parent */
{ /* pid hold id of child */
i = 0;
while (i < 1) { /* allow for 3 semaphore sets */
nsops = 2;
______________________________________________________________ 113
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
/* wait for semaphore to reach zero */
sops[0].sem_num = 0;
sops[0].sem_op = 0; /* wait for semaphore flag to become zero
*/
sops[0].sem_flg = SEM_UNDO; /* take off semaphore asynchronous
*/
sops[1].sem_num = 0;
sops[1].sem_op = 1; /* increment semaphore -- take control of
track */
sops[1].sem_flg = SEM_UNDO | IPC_NOWAIT; /* take off semaphore
*/
/* Recap the call to be made. */
(void) fprintf(stderr,"\nsemop:Parent Calling semop(%d,
&sops, %d) with:", semid, nsops);
for (j = 0; j < nsops; j++)
{
(void) fprintf(stderr, "\n\tsops[%d].sem_num = %d, ", j,
sops[j].sem_num);
(void) fprintf(stderr, "sem_op = %d, ", sops[j].sem_op);
(void) fprintf(stderr, "sem_flg = %#o\n", sops[j].sem_flg);
}
/* Make the semop() call and report the results. */
if ((j = semop(semid, sops, nsops)) == -1) {
perror("semop: semop failed");
}
else
{
(void) fprintf(stderr, "semop: semop returned %d\n", j);
(void) fprintf(stderr, "Parent Process Taking Control of
Track: %d/3 times\n", i+1);
sleep(5); /* Do nothing for 5 seconds */
nsops = 1;
/* wait for semaphore to reach zero */
sops[0].sem_num = 0;
sops[0].sem_op = -1; /* Give UP COntrol of track */
sops[0].sem_flg = SEM_UNDO | IPC_NOWAIT; /* take
off semaphore, asynchronous */
if ((j = semop(semid, sops, nsops)) == -1) {
perror("semop: semop failed");
}
else
(void) fprintf(stderr, "Parent Process Giving up
Control of Track: %d/3 times\n", i+1);
sleep(5); /* halt process to allow child to
catch semaphor change first */
}
++i;
}
}
}
______________________________________________________________ 114
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Steps:
To execute:
To modify:
______________________________________________________________ 115
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab 12
Objective:
To write a simple program of Inter process communication between two process
using shared memory, build it, and execute it using the target board.
Client Program:
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdio.h>
#define SHMSZ
27
main()
{
int shmid;
key_t key;
char *shm, *s;
/*
* We need to get the segment named
* "5678", created by the server.
*/
key = 5678;
/*
* Locate the segment.
*/
if ((shmid = shmget(key, SHMSZ, 0666)) < 0) {
perror("shmget");
exit(1);
}
/*
* Now we attach the segment to our data space.
*/
if ((shm = shmat(shmid, NULL, 0)) == (char *) -1) {
perror("shmat");
exit(1);
}
/*
* Now read what the server put in the memory.
*/
for (s = shm; *s != NULL; s++)
putchar(*s);
putchar('\n');
/*
* Finally, change the first character of the
* segment to '*', indicating we have read the segment.*/
*shm = '*';
exit(0);
}
______________________________________________________________ 116
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Server Program:
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdio.h>
#define SHMSZ
27
main()
{
char c;
int shmid;
key_t key;
char *shm, *s;
/*
* We'll name our shared memory segment
* "5678".
*/
key = 5678;
/*
* Create the segment.
*/
if ((shmid = shmget(key, SHMSZ, IPC_CREAT | 0666)) < 0) {
perror("shmget");
exit(1);
}
/*Now we attach the segment to our data space.*/
if ((shm = shmat(shmid, NULL, 0)) == (char *) -1) {
perror("shmat");
exit(1);
}
/*Now put some things into the memory for the
other process to read.*/
s = shm;
for (c = 'a'; c <= 'z'; c++)
*s++ = c;
*s = NULL;
/*
* Finally, we wait until the other process
* changes the first character of our memory
* to '*', indicating that it has read what
* we put there.
*/
printf("Run Clinet Process\n");
while (*shm != '*')
sleep(1);
exit(0);
}
______________________________________________________________ 117
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Steps:
To execute:
To modify:
Steps for server program:
______________________________________________________________ 118
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
______________________________________________________________ 119
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
8.3 Interfacing Basic ASK based linux programs with ARM9 Target with
linux
Lab13
Objective:
To study the simple LED Interface with ARM9 target board
Part List:
Program Description:
This Program will glow alternate LED on S-Lcd module
Pin Assignment:
Connection between S-Lcd connector to J11 connector of target board
Procedure:
______________________________________________________________ 120
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Editing program
______________________________________________________________ 121
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Program:-
#include <linux/ioctl.h>
#define DEVICE_NAME "SLCD_LED"
#define MAJOR_NUM 60
#define
#define
#define
#define
INIT_GPIO_B
_IOWR(MAJOR_NUM, 0, int *)
GPIO_B_CLEAR
_IOWR(MAJOR_NUM, 1, int *)
GPIO_B_SET
_IOWR(MAJOR_NUM, 2, int *)
GPIO_B_READ
_IOWR(MAJOR_NUM, 3, int *)
#include
#include
#include
#include
#include
#include
#include
<stdio.h>
<unistd.h>
<stdlib.h>
<errno.h>
<fcntl.h>
<string.h>
<sys/ioctl.h>
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
{
printf("ioctl_set_msg failed:%d\n", ret_val);
exit(-1);
}
}
static void init_gpio_B(int gpio)
{
int ret_val;
ret_val = ioctl(gpio, INIT_GPIO_B);
if (ret_val < 0)
{
printf("ioctl_set_msg failed:%d\n", ret_val);
exit(-1);
}
}
int main()
{
int gpio;
int n,i;
/* gpio test */
if ((gpio = open("/dev/SLCD_LED", O_RDWR)) < 0)
FATAL;
init_gpio_B(gpio);
while(1)
{
sleep(1);
port_B_clear(gpio, 0x01500400);
port_B_set(gpio, 0x00A00A00);
sleep(1);
port_B_clear(gpio, 0x00A00A00);
port_B_set(gpio, 0x01500400);
}
if (close(gpio) < 0)
FATAL;
return 0;
}
EXERCISES
EG1
EG2
EG3
______________________________________________________________ 123
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab14
Objective:
To study the simple 7-segment Interface of with ARM9 target board
Part List:
Program Description:
This Program will display 0-9 digit on 7-segment on S-Lcd module
Pin Assignment:
Connection between S-Lcd connector to J12 connector of ARM-9target board
Procedure:
______________________________________________________________ 124
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Editing program
cp lab14.o /root/tftpboot
______________________________________________________________ 125
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Program:-
#include
#include
#include
#include
#include
<stdio.h>
<stdlib.h>
<fcntl.h>
<unistd.h>
<sys/ioctl.h>
/* open */
/* exit */
#include "7segment.h"
display_digit(char digit,int file_desc, struct Segment_display
*message)
{
int ret_val;
message->digit = digit;
ret_val = ioctl(file_desc, DISPLAY_SEGMENT, message);
if (ret_val < 0) {
printf("ioctl_set_msg failed:%d\n", ret_val);
exit(-1);
}
}
segment_init(int file_desc)
{
int ret_val;
ret_val = ioctl(file_desc, SEGMENT_INIT);
if (ret_val < 0) {
printf("ioctl_set_msg failed:%d\n", ret_val);
exit(-1);
}
}
main()
{
int file_desc_7segment, ret_val,i;
struct Segment_display display;
file_desc_7segment = open("/dev/SLCD_7SEGMENT", 0);
if (file_desc_7segment < 0) {
printf("Can't open device file: %s\n", DEVICE_FILE_NAME);
exit(-1);
}
segment_init(file_desc_7segment);
for( i=0; i<=9; i++ )
{
display_digit(i,file_desc_7segment,&display);
printf("i=%d\n",i);
sleep(1);
}
close(file_desc_7segment);
}
______________________________________________________________ 126
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab15
Objective:
To study the simple LCD Interface of with ARM9 target board
Part List:
Program Description:
This Program will display string on LCD of S-Lcd module
Pin Assignment:
Connection between S-Lcd connector to J11 connector of ARM-9target board
Procedure:
______________________________________________________________ 127
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Editing program
ls
cp lab15.o /root/tftpboot
______________________________________________________________ 128
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Program:-
#include <linux/ioctl.h>
#include
#include
#include
#include
#include
#include
#include
<stdio.h>
<unistd.h>
<stdlib.h>
<errno.h>
<fcntl.h>
<string.h>
<sys/ioctl.h>
#include "lcd.h"
lcd_cmd(0x01,file_desc_lcd,&display);
//lcd clear cmd
lcd_string(1,0,"Edutech Systems", file_desc_lcd, &display);
//displays string
lcd_string(2,0,"baroda lab15", file_desc_lcd, &display);
//displays string
close(file_desc_lcd);
return 0;
}
______________________________________________________________ 129
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
EXERCISES
EG4
Write a simple program to display single character on LCD
EG5
Write a simple program to display single character on different
location of LCD
EG6
Write a simple program to display string on LCD
EG7
Write a simple program to display string on different line number on
LCD
______________________________________________________________ 130
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab16
Objective:
To study the simple switch Interface with ARM9 target board
Part List:
Program Description:
This Program will display switch number on minicom of hyperterminal on S-Lcd
module
Pin Assignment:
Connection between S-Lcd connector to J11 connector of ARM-9target board
Procedure:
______________________________________________________________ 131
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Editing program
______________________________________________________________ 132
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Program:-
#include <linux/ioctl.h>
#include
#include
#include
#include
#include
#include
#include
#define
#define
#define
#define
#define
<stdio.h>
<unistd.h>
<stdlib.h>
<errno.h>
<fcntl.h>
<string.h>
<sys/ioctl.h>
DEVICE_NAME "SLCD_KEY"
MAJOR_NUM 66
AT91_GPIO_MAGIC ('o')
AT91_GPIO_IOC_INP
_IO(AT91_GPIO_MAGIC, 1)
INIT_SWITCH
_IO(AT91_GPIO_MAGIC, 2)
______________________________________________________________ 133
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
______________________________________________________________ 134
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab17
Objective:
To study the simple relay Interface with ARM9 target board
Part List:
Program Description:
This Program will switch relay simultaneously
Pin Assignment:
Connection between relay connector J1 to J12 connector of ARM-9target board
Procedure:
______________________________________________________________ 135
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Editing program
ls
cp lab17.o /root/tftpboot
______________________________________________________________ 136
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Program:-
#include <linux/ioctl.h>
#include
#include
#include
#include
#include
#include
#include
#include
<stdio.h>
<unistd.h>
<stdlib.h>
<errno.h>
<fcntl.h>
<string.h>
<sys/ioctl.h>
"relayuser.h"
int main()
{
int file_desc_rel;
signed long int temp,count;
int i = 0;
struct relay step;
/* gpio test */
if ((file_desc_rel = open("/dev/ASK06_RELAY", O_RDWR)) < 0)
FATAL;
printf("enter value ...................->
scanf("%d",&count );
");
init_relay(file_desc_rel);
for(temp = 0; temp < count; temp++)
{
right(i,file_desc_rel,&step); //use as per program
application;
i++;
if ( i > 3 )
i = 0;
}
if (close(file_desc_rel) < 0)
FATAL;
return 0;
}
______________________________________________________________ 137
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab18
Objective:
To study the simple stepper motor Interface with ARM9 target board
Part List:
Program Description:
This Program will rotate stepper motor in clockwise direction in terms of
degree inserted by keyboard on minicom or hyperteminal
Pin Assignment:
Connection between stepper motor connector J1 to J12 connector of ARM-9target
board
Procedure:
______________________________________________________________ 138
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Editing program
ls
cp lab18.o /root/tftpboot
______________________________________________________________ 139
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Program:-
#include <linux/ioctl.h>
#include
#include
#include
#include
#include
#include
#include
<stdio.h>
<unistd.h>
<stdlib.h>
<errno.h>
<fcntl.h>
<string.h>
<sys/ioctl.h>
#include "lcd.h"
#include "sm.h"
#define FATAL do { fprintf(stderr, "Error at line %d, file %s (%d)
[%s]\n", \
__LINE__, __FILE__, errno, strerror(errno)); exit(1); } while(0)
int data;
struct lcd_display display;
int main()
{
int file_desc_lcd, file_desc_stepper;
signed long int temp,deg,count;
int i = 0;
struct stepper_motor step;
file_desc_lcd = open("/dev/ ASK01_LCD", 0);
if (file_desc_lcd < 0)
{
printf("Can't open >>>> lcd <<<< device file: %s\n",
DEVICE_FILE_NAME_LCD);
exit(-1);
}
file_desc_stepper = open("/dev/ ASK05_STMOTOR", O_RDWR);
if (file_desc_stepper < 0)
{
printf("Can't open >>>> stepper motor <<<<device file:
%s\n", DEVICE_FILE_NAME_SM);
exit(-1);
}
init_lcd(file_desc_lcd);
//initialise matrix keyboard
init_steppermotor(file_desc_stepper);
lcd_cmd(0x01,file_desc_lcd,&display);
//lcd clear cmd
lcd_string(1,0,"lcd displys CAR", file_desc_lcd, &display);
//displays string
sleep(1);
______________________________________________________________ 140
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
while(1)
{
lcd_cmd(0x01,file_desc_lcd,&display);
//lcd clear cmd
lcd_string(1,0,"ST-MOTOR program", file_desc_lcd,
&display); //displays string
printf("Enter Value in Degree...................-> ");
scanf("%d",° );
count = deg * 0.5556;
printf("\n\n Stepper-Motor roatating in clockwise\n\n");
lcd_cmd(0x01,file_desc_lcd,&display);
//lcd clear cmd
lcd_string(1,0,"StepperMotor in", file_desc_lcd,
&display);
lcd_string(2,0,"Clockwise", file_desc_lcd, &display);
for(temp = 0; temp < count; temp++)
{
clockwise(i,file_desc_stepper,&step);
i++;
if ( i > 3 )
i = 0;
}
}
close(file_desc_lcd);
close(file_desc_stepper);
return 0;
}
EXERCISES
EG8
EG9
______________________________________________________________ 141
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab19
Objective:
To study the simple 7-segment keyboard Interface with ARM9 target board
Part List:
Program Description:
This Program will displays number 0-9 on all the segments of 7segkeyboard ASK.
Pin Assignment:
Connection between 7segment-keyboard J1 to J12 connector of ARM-9target board
and 7segment-keyboard J2 to J11 connector of ARM-9target board
Procedure:
______________________________________________________________ 142
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Editing program
ls
cp lab19.o /root/tftpboot
______________________________________________________________ 143
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Program:-
#include
#include
#include
#include
#include
<stdio.h>
<stdlib.h>
<fcntl.h>
<unistd.h>
<sys/ioctl.h>
/* open */
/* exit */
#include "7segment_user.h"
main()
{
int file_desc, ret_val, data_change, digit_change;
struct Segment_display display;
file_desc = open("/dev/ASK02_7SEGMENT", 0);
if (file_desc < 0) {
printf("Can't open device file: %s\n", DEVICE_FILE_NAME);
exit(-1);
}
segment_kb_init(file_desc);
for( data_change = 0 ; data_change <= 9 ; data_change++ )
{
seg_1(
seg_2(
seg_3(
seg_4(
data_change
data_change
data_change
data_change
,
,
,
,
file_desc
file_desc
file_desc
file_desc
,
,
,
,
&display
&display
&display
&display
);
);
);
);
printf("data_change = %d\n",data_change );
sleep(1);
}
close(file_desc);
}
______________________________________________________________ 144
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab20
Objective:
To study the simple LCD Interface with ARM9 target board
Part List:
Program Description:
This Program will displays string on lcd of lcd-keboard ASK
Pin Assignment:
Connection between Lcd-keyboard J1 to J11 connector of ARM-9target
Procedure:
______________________________________________________________ 145
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Editing program
ls
cp lab20.o /root/tftpboot
______________________________________________________________ 146
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Program:-
#include <linux/ioctl.h>
#include
#include
#include
#include
#include
#include
#include
<stdio.h>
<unistd.h>
<stdlib.h>
<errno.h>
<fcntl.h>
<string.h>
<sys/ioctl.h>
#include "lcd.h"
#define FATAL do { fprintf(stderr, "Error at line %d, file %s (%d)
[%s]\n", \
__LINE__, __FILE__, errno, strerror(errno)); exit(1); } while(0)
int data;
struct lcd_display display;
int main()
{
int file_desc_lcd;
file_desc_lcd = open("/dev/ ASK01_LCD", 0);
if (file_desc_lcd < 0)
{
printf("Can't open >>>> lcd <<<< device file: %s\n",
DEVICE_FILE_NAME_LCD);
exit(-1);
}
init_lcd(file_desc_lcd);
lcd_cmd(0x01,file_desc_lcd,&display);
//lcd clear cmd
lcd_string(1,0,"Edutech Systems", file_desc_lcd, &display);
//displays string
lcd_string(2,0,"Vadodara", file_desc_lcd, &display);
//displays string
close(file_desc_lcd);
return 0;
}
______________________________________________________________ 147
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab21
Objective:
To study the simple LCD commands for lcd with ARM9 target board
Part List:
Program Description:
This Program will displays string shifting left and right on LCD of lcdkeboard ASK
Pin Assignment:
Connection between Lcd-keyboard J1 to J11 connector of ARM-9target
Procedure:
______________________________________________________________ 148
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Editing program
______________________________________________________________ 149
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Program:-
#include <linux/ioctl.h>
#include
#include
#include
#include
#include
#include
#include
<stdio.h>
<unistd.h>
<stdlib.h>
<errno.h>
<fcntl.h>
<string.h>
<sys/ioctl.h>
#include "lcd.h"
#define FATAL do { fprintf(stderr, "Error at line %d, file %s (%d)
[%s]\n", \
__LINE__, __FILE__, errno, strerror(errno)); exit(1); } while(0)
lcd_cmd(0x01,file_desc_lcd,&display);
//lcd clear cmd
lcd_string(1,0,"Edutech Systems", file_desc_lcd, &display);
//displays string
lcd_string(2,0,"Vadodara", file_desc_lcd, &display);
//displays string
//shift right
cmd
Delay(100);
______________________________________________________________ 150
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
}
for(i = 0; i <=5; i++)
{
lcd_cmd(0x18,file_desc_lcd,&display);
//shift left
cmd
Delay(100);
}
close(file_desc_lcd);
return 0;
}
EXERCISES
EG10 Write a simple program to display string and shift string in left direction in
LCD of LCD-KB with required delay.
EG11 Write a simple program to display string and shift string in right direction in
LCD of LCD-KB with required delay.
______________________________________________________________ 151
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab22
Objective:
To study the simple 5x5 matrix keyboard interfacing on with ARM9 target board
Part List:
Program Description:
This Program will displays key number of 5x5 matrix keyboard on LCD of
lcd-keboard ASK
Pin Assignment:
Connection between Lcd-keyboard J1 to J11 connector of ARM-9target
Procedure:
______________________________________________________________ 152
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Editing program
ls
cp lab22.o /root/tftpboot
______________________________________________________________ 153
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Program:-
#include <linux/ioctl.h>
#include
#include
#include
#include
#include
#include
#include
<stdio.h>
<unistd.h>
<stdlib.h>
<errno.h>
<fcntl.h>
<string.h>
<sys/ioctl.h>
#include "kb.h"
#include "lcd.h"
#define FATAL do { fprintf(stderr, "Error at line %d, file %s (%d)
[%s]\n", \
__LINE__, __FILE__, errno, strerror(errno)); exit(1); } while(0)
int data;
struct lcd_display display;
int main()
{
int file_desc_lcd, file_desc_keyboard;
int key;
while(1)
{
key = read_keyboard(file_desc_keyboard,data);
______________________________________________________________ 154
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
lcd_cursor_set(2, 0, file_desc_lcd, &display);
key_on_lcd(key,file_desc_lcd);
printf("\n user key value is = %d \n",key);
sleep(1);
}
close(file_desc_keyboard);
close(file_desc_lcd);
return 0;
}
int key_on_lcd(int key1,int file_desc_lcd)
{
unsigned int row,col;
row = key1/ 10;
col = key1% 10;
row = row + 48;
col = col + 48;
lcd_data(row,file_desc_lcd,&display);
lcd_data(col,file_desc_lcd,&display);
}
EXERCISES
EG12 Write a simple program to display key number on LCD of LCD-KB.
( like A , B , C , D etc.)
EG13 Write a simple program to display different string on LCD while pressing
different key of LCD-KB
EG14 Write a simple program to explore different LCD command on LCD.
______________________________________________________________ 155
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab23
Objective:
To study the simple CG-RAM programming of LCD with ARM9 target board
Part List:
Program Description:
This Program will display car on LCD when we press keys on 5x5 matrix
keyboard on lcd-keyboard ASK
Press A for displaying car
Press B for shifting car on right sight
Press C for shifting car on left sight
Pin Assignment:
Connection between Lcd-keyboard J1 to J11 connector of ARM-9target
Procedure:
______________________________________________________________ 156
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Editing program
ls
cp lab23.o /root/tftpboot
______________________________________________________________ 157
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Program:-
#include
#include
#include
#include
#include
#include
#include
#include
<linux/ioctl.h>
<stdio.h>
<unistd.h>
<stdlib.h>
<errno.h>
<fcntl.h>
<string.h>
<sys/ioctl.h>
#include "kb.h"
#include "lcd.h"
int i = 0;
file_desc_lcd = open("/dev/ASK01_LCD", 0);
if (file_desc_lcd < 0)
{
printf("Can't open >>>> lcd <<<< device file: %s\n",
DEVICE_FILE_NAME_LCD);
exit(-1);
}
file_desc_keyboard = open("/dev/ASK01_MATKB", O_RDWR);
if (file_desc_keyboard < 0)
{
printf("Can't open >>>> keyboard <<<<device file: %s\n",
DEVICE_FILE_NAME_KEYBOARD);
exit(-1);
}
init_keyboard(file_desc_keyboard);
keyboard
init_lcd(file_desc_lcd);
keyboard
//initialise matrix
//initialise matrix
lcd_cmd(0x01,file_desc_lcd,&display);
//lcd clear cmd
lcd_string(1,0,"lcd displys CAR", file_desc_lcd, &display);
//displays string
car_on_cgram(file_desc_lcd);
sleep(1);
______________________________________________________________ 158
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
while(1)
{
lcd_cmd(0x01,file_desc_lcd,&display);
//lcd clear cmd
lcd_string(1,0,"Press 1 for CAR", file_desc_lcd,
&display); //displays string
while((key = read_keyboard(file_desc_keyboard,data)) ==
55);
if (key == 20)
car on lcd
{
car_on_lcd(file_desc_lcd);
sleep(1);
while((key =
read_keyboard(file_desc_keyboard,data)) != 30);
for(shift = 0; shift <=15; shift++)
{
lcd_cmd(0x1C,file_desc_lcd,&display);
//shift right cmd;shift car in right direction
sleep(1);
}
while((key =
read_keyboard(file_desc_keyboard,data)) != 40);
for(shift = 0; shift <=15; shift++)
{
lcd_cmd(0x18,file_desc_lcd,&display);
//shift left cmd;shift car in left direction
sleep(1);
}
}
else
{
lcd_string(1,0,"Press 1 for CAR", file_desc_lcd,
&display); //displays string
}
sleep(1);
}
close(file_desc_keyboard);
close(file_desc_lcd);
return 0;
}
int car_on_cgram(int file_desc_lcd)
{
lcd_cmd(0x01,file_desc_lcd,&display);
lcd_cmd(0x02,file_desc_lcd,&display);
______________________________________________________________ 159
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
lcd_cmd(0x40,file_desc_lcd,&display);
mode cmd address = 0x40 first add of first character
//cg-ram enter
lcd_data(0x00,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x01,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x03,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x1F,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x1F,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x1F,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x1F,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x0F,file_desc_lcd,&display);
for making car in cg_ram location 0-6
//data
lcd_data(0x1F,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x1F,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x03,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x03,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x1F,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x1F,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x1F,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x1F,file_desc_lcd,&display);
for making car in cg_ram location 0-6
//data
lcd_data(0x1E,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x1F,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x11,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x11,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x1F,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x1F,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x1F,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x1F,file_desc_lcd,&display);
for making car in cg_ram location 0-6
//data
lcd_data(0x00,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x00,file_desc_lcd,&display);
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
lcd_data(0x18,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x1F,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x1F,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x1F,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x1F,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x1F,file_desc_lcd,&display);
for making car in cg_ram location 0-6
//data
lcd_data(0x00,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x00,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x00,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x1C,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x1E,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x1F,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x1F,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x1F,file_desc_lcd,&display);
for making car in cg_ram location 0-6
//data
lcd_data(0x07,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x07,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x00,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x00,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x00,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x00,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x00,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x00,file_desc_lcd,&display);
for making car in cg_ram location 0-6
//data
lcd_data(0x1C,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x1C,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x00,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x00,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x00,file_desc_lcd,&display);
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
//data
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
lcd_data(0x00,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x00,file_desc_lcd,&display);
for making car in cg_ram location 0-6
lcd_data(0x00,file_desc_lcd,&display);
for making car in cg_ram location 0-6
//data
//data
//data
}
int car_on_lcd(int file_desc_lcd)
{
lcd_cmd(0x01,file_desc_lcd,&display);
lcd_cmd(0x80,file_desc_lcd,&display);
first char cmd; row0-column0
lcd_data(0x00,file_desc_lcd,&display);
ram data col 0
lcd_data(0x01,file_desc_lcd,&display);
ram data col 1
lcd_data(0x02,file_desc_lcd,&display);
ram data col 2
lcd_data(0x03,file_desc_lcd,&display);
ram data col 3
lcd_data(0x04,file_desc_lcd,&display);
ram data col 4
lcd_cmd(0xC0,file_desc_lcd,&display);
cmd column 0
lcd_data(0x05,file_desc_lcd,&display);
cg-ram data
//second row
lcd_cmd(0xC4,file_desc_lcd,&display);
cmd column 4
lcd_data(0x06,file_desc_lcd,&display);
cg-ram data
}
//second row
//second row
//second row
EXERCISES
EG15 Write a simple program to explain CG-RAM programming to make edutech
logo.
______________________________________________________________ 162
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab24
Objective:
To study the simple on-chip RTC Interface with ARM9 target board
Part List:
Program Description:
This Program will displays time on minicom or hyperterminal
Pin Assignment:
Connection between Lcd-keyboard J1 to J11 connector of ARM-9target
Procedure:
[root@EDUTECH~]:cd /home/example
[root@EDUTECH~]:./lab24.o
______________________________________________________________ 163
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Editing program
ls
cp lab24.o /root/tftpboot
______________________________________________________________ 164
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Program:-
#include
#include
#include
#include
#include
<stdio.h>
<stdlib.h>
<fcntl.h>
<unistd.h>
<sys/ioctl.h>
/* open */
/* exit */
#include "lcd.h"
#include "rtc.h"
struct rtc_time time_date;
void Delay(int delay)
{
int i,j;
for(i=0;i<=delay;i++)
{
for(j=0;j<=1000;j++){}
}
}
main()
{
int file_desc_lcd, file_desc_rtc;
struct lcd_display display;
time_date.sec
time_date.min
time_date.hour
time_date.year
time_date.mon
time_date.date
time_date.wday
=
=
=
=
=
=
=
50;
59;
23;
1999;
12;
31;
1;
______________________________________________________________ 165
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
sleep(1);
rtc_init(file_desc_rtc, &time_date);
while(1)
{
rtc_read(file_desc_rtc, &time_date);
}
close(file_desc_rtc);
close(file_desc_lcd);
}
______________________________________________________________ 166
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab25
Objective:
To study the enrollment of fingerprint with ARM-9 target board
Part List
File List
: lcd.h, kb.h
Program Description:
This Program will Enroll ID number and store Number to Finger Print.
Pin Assignment:
Procedure:
______________________________________________________________ 167
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Editing program
______________________________________________________________ 168
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Output:
Following is the output shown on the screen of ASK1 ( LCD-KB) when the program is
executed.
Edutech System
Finer Print
Connecting
Connection Done
Entering
Master Mode
Master Mode DONE
A=Enroll
Enter ID
If Enroll will be selected then
Enroll 1 start
Put Finger...
Enroll 1 done
Lift Finger
Enroll 2 start
Put Finger...
Enroll 2 done
Lift Finger
______________________________________________________________ 169
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Flow chart:
______________________________________________________________ 170
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab26
Objective:
To study the identify ID of fingerprint with ARM-9 target board
Part List
File List
: lcd.h, kb.h
Program Description:
This Program will Identify ID number stored on Finger Print.
Pin Assignment:
Procedure:
______________________________________________________________ 171
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Editing program
______________________________________________________________ 172
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Output:
Following is the output shown on the screen of ASK-LCD when the program is
executed.
Edutech System
Finer Print
connecting...
Connection Done
Entering...
Master Mode
Master Mode DONE
F1=Identify
If Identify will be selected then
Identify Start
Put ur finger...
ID=3
Identify Done
______________________________________________________________ 173
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Flow chart:
______________________________________________________________ 174
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab27
Objective:
To study the delete ID number of fingerprint with ARM-9 target board
Part List
File List
: lcd.h, kb.h
Program Description:
This Program will Delete ID number stored on Finger Print.
Pin Assignment:
Procedure:
______________________________________________________________ 175
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Editing program
______________________________________________________________ 176
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Output:
Following is the output shown on the screen of ASK-LCD when the program is
executed.
Edutech System
Finer Print
connecting...
Connection Done
Entering...
Master Mode
Master Mode DONE
D=Delete
Enter ID
If Delete will be selected then
Entering...
Delete Mode
ID 3 Delete
Delete Done
______________________________________________________________ 177
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Flow chart:
EXERCISES
EG16 Write a simple program to enroll, identify and delete finger-print id using
ASK-LCD in a single program.
______________________________________________________________ 178
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab28
Objective:
To write a program to demonstrate basic working of RFID with ARM-9 target board
Part List
File List
Program Description:
This Program will display holder number on ASK-1 LCD-KB
Pin Assignment:
Procedure:
______________________________________________________________ 179
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Editing program
______________________________________________________________ 180
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Flow chart:
______________________________________________________________ 181
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab29
Objective:
To write a program to demonstrate basic working of RFID with on-chip RTC of ARM9
CPU and LCD with ARM-9 target board
Part List
File List
Program Description:
This Program will display holder number with time on ASK-1 LCD-KB
Pin Assignment:
Procedure:
______________________________________________________________ 182
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Editing program
______________________________________________________________ 183
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Flow chart:
______________________________________________________________ 184
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
EXERCISES
EG17 Write a simple program to demonstrate basic working of RFID with ARM-9
target board using SLCD
______________________________________________________________ 185
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab30
Objective:
To write a program to initialize the GSM module with ARM-9 target board
Part List
Program Description:
This Program will initialize the GSM module.
Pin Assignment:
Procedure:
______________________________________________________________ 186
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Editing program
______________________________________________________________ 187
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Output:
[root@EDUTECH:/home/default] ./lab30.o
Serial port is initialised
Receiving data in buffer...Output
AT
OK
###########...Connection Succcessful... ##########
______________________________________________________________ 188
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab31
Objective:
To write a program to call a number using GSM module with ARM-9 target board
Part List
Program Description:
This Program will call the mobile number with the help of GSM module.
Pin Assignment:
Procedure:
______________________________________________________________ 189
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Editing program
cp lab31.o /root/tftpboot
______________________________________________________________ 190
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Output:
[root@EDUTECH:/home/default] ./lab31.o
Serial port is initialised
Receiving data in buffer...Output
AT
OK
###########...Connection Succcessful... ##########
Enter mobile number
9974772530
########### Calling...!! #############
Receiving data in buffer...Output
ATD9974772530;
###########...Call Succcessful... ##########
EXERCISES
EG18 Write a simple program to give a call using GSM module by fix mobile number
through program
______________________________________________________________ 191
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab32
Objective:
To write a program to give a miss call using GSM module with ARM-9 target board
Part List
Program Description:
This Program will miss call to the given number using GSM module.
Pin Assignment:
Procedure:
______________________________________________________________ 192
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Editing program
______________________________________________________________ 193
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Output:
[root@EDUTECH:/home/default] ./lab32.o
Serial port is initialised
Receiving data in buffer...Output
AT
OK
###########...Connection Succcessful... ##########
Enter mobile number
9974772530
########### Calling...!! #############
Receiving data in buffer...Output
ATD9974772530;
###########...Call Succcessful... ##########
###########...Hanging up...!! #############received SIGIO signal.
Receiving data in buffer...Output
ATH
OK
###########...Call Suspended... ##########
EXERCISES
EG19 Write a simple program to give a miss call using GSM module by fix mobile
number through program
______________________________________________________________ 194
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab33
Objective:
To write a program to send sms using GSM module with ARM-9 target board
Part List
Program Description:
This Program will send sms to the given number using GSM module.
Pin Assignment:
Procedure:
______________________________________________________________ 195
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Editing program
______________________________________________________________ 196
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Output:
[root@EDUTECH:/home/default] ./lab34.o
Serial port is initialised
Receiving data in buffer...Output
AT
OK
###########...Connection Succcessful... ##########
Enter mobile number
9974772530
Enter content of SMS..
Input :hello world
########### ...Sending SMS...!! #############
Receiving data in buffer..
Output
###########...SMS Sent... ##########
EXERCISES
EG20 Write a simple program to send SMS using GSM module on fix mobile number
and fix message through program.
______________________________________________________________ 197
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab34
Objective:
To write a program to read sms of SIM card using GSM module with ARM-9 target
board
Part List
Program Description:
This Program will read sms of SIM card using GSM module.
Pin Assignment:
Procedure:
______________________________________________________________ 198
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Editing program
______________________________________________________________ 199
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Output:
[root@EDUTECH:/home/default] ./lab34.o
Serial port is initialised
Receiving data in buffer...Output
AT
OK
###########...Connection Succcessful... ##########
####### SMS read..#######
Enter SMS index No...
1
Receiving data in buffer...Output
AT+CMGR=1
+CMGR: "REC READ","For You",,"08/11/17,09:08:32+22"
Living in the Favorable & Non-Favourable situation is PART OF LIVING But
Smiling in all Situations is called ART OF LIVING. Keep Smiling!!
OK
EXERCISES
EG21 Write a simple program to read fix number of SMS of SIM card using GSM
module.
______________________________________________________________ 200
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab35
Objective:
To write a program to read phonebook using GSM module with ARM-9 target board
Part List
Program Description:
This Program will read phonebook contacts of SIM card.
Pin Assignment:
Procedure:
______________________________________________________________ 201
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Editing program
______________________________________________________________ 202
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Output:
[root@EDUTECH:/home/default] ./lab35.o
Serial port is initialised
Receiving data in buffer...Output
AT
OK
###########...Connection Succcessful... ##########
####### Phone book read..#######
Enter Contact index No...
4
Receiving data in buffer...Output
AT+CPBR=10
+CPBR: 10,"9975639116",129,"Jigar Home
OK
EXERCISES
EG22 Write a simple program to read fix number of phonebook using GSM module.
______________________________________________________________ 203
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab36
Objective:
To write a program to search phonebook contacts of SIM card using GSM module
with ARM-9 target board
Part List
Program Description:
This Program will search phonebook contacts of SIM card.
Pin Assignment:
Procedure:
______________________________________________________________ 204
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Editing program
______________________________________________________________ 205
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Output:
Serial port is initialised
Receiving data in buffer...Output
AT
OK
###########...Connection Succcessful... ##########
####### Phonebook Search #######
Enter Character...
H
Receiving data in buffer...Output
AT+CPBF="H"
+CPBF: 37,"9935601273",129,"Herat"
+CPBF: 38,"9758033171",129,"Hiren"
+CPBF: 39,"02874449848",129,"HOME"
OK
EXERCISES
EG23 Write a simple program to search phonebook contacts by fix character of SIM
card using GSM module.
______________________________________________________________ 206
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab37
Objective:
To write a program to call, miss call, and message using GSM module with ARM-9
target board
Part List
File List
: kb.h, lcd.h
Program Description:
This Program will first ask for mobile number.after entering mobile number by ASK-1,
it will ask for selection of call, miss call or message. On proper selection it will
execute that application on GSM module.
Pin Assignment:
Procedure:
______________________________________________________________ 207
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Editing program
______________________________________________________________ 208
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab38
Objective:
To write a program to print the message on thermal paper using thermal printer
module with ARM-9 target board
Part List
Program Description:
This Program will print the message on thermal paper using thermal printer module
with ARM-9 target board
Pin Assignment:
Procedure:
______________________________________________________________ 209
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Editing program
______________________________________________________________ 210
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Output:
The below lines will get printed on thermal paper in normal default font size.
Ketan Patel
Edutech Systems
304-Sarjan Complex
Dandia Dazar
Vadodara
______________________________________________________________ 211
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Lab39
Objective:
To write a program to print the different size of fonts of message on thermal paper
using thermal printer module with ARM-9 target board.
Part List
File List
: kb.h, lcd.h
Program Description:
This program will print the different size of fonts of message on thermal paper using
thermal printer module.
Pin Assignment:
Procedure:
______________________________________________________________ 212
Edutech Systems
____________________________________________________________________________
AT91RM9200
Workbook
____________________________________________________________________________
Editing program
Output:
The below lines will get printed on thermal paper in different fonts size as
entered by user via LCD-Keyboard.
Ketan Patel
Edutech Systems
304-Sarjan Complex
Dandia Dazar
Vadodara
______________________________________________________________ 213
Edutech Systems