Experiment No 1: 1. Study of Arm Evaluation System
Experiment No 1: 1. Study of Arm Evaluation System
Experiment No 1: 1. Study of Arm Evaluation System
Experiment No 1
Experiment No 2
Connection Details:
Variable Pot output(Analog) 0 to 3.3 Volt connect to P0.28 burg pin by burg wire.
2.1.ADC Program:
#include <LPC214x.H>
#include <stdio.h>
for(i=0;i<=Time;i++)
for(j=0;j<110;j++);
}
/*********************************************************************************************
* UART0 Initialization
*
*********************************************************************************************/
void UART0_Init()
{
PINSEL0 = 0x05; /* Enable RxD0 and TxD0 */
U0LCR = 0x83; /* DLAB=1, 8 bits, no Parity, 1 Stop bit */
U0DLL = 0x86; /* 9600 Baud Rate @60MHz VPB Clock */
U0DLM = 0x01;
U0LCR = 0x03; /* DLAB = 0 */
VPBDIV = 0x01; /*VLSI Pheripheral Bus clock as Processor clock*/
}
/*********************************************************************************************
* ADC initialization
*
*********************************************************************************************/
void ADC_Init()
{
PINSEL1 = 0x01000000; /* P0.28 configure to channel AD0.1 */
AD0CR = 0x00230602; /* Setup A/D: 10-bit AIN0 @ 3MHz */
}
Used Formula:
Digital O/P = Analag I/P X 2n /Vref
Where,
N = No of bits per ADC(1024).
Vref =Refernce Voltage(3.3V)
Result:
Thus the analog input converted to digital form and display the digtal output on Hyper
Teriminal.Output was verified by formula.
Connection Details:
P0.25 connect to +ve(Red) Probe teriminal of CRO/DSO.
Gnd connect to -ve(Block) Probe teriminal of CRO/DSO.
#include<LPC214x.H>
int main(void)
{
unsigned int DAC_Val;
VPBDIV = 0x01;
PINSEL1 = 0x00080000; //ENABLE DAC PIN (P0.25)
while (1)
{
DAC_Val = 0x03FF; // For +ve Peak
DAC_Val=DAC_Val<<6;
DACR=DAC_Val;
msdelay(100);
#include<LPC214x.H>
int main(void)
{ unsigned int DAC_Val,i;
VPBDIV = 0x01;
PINSEL1 = 0x00080000; //ENABLE DAC PIN (P0.25)
DAC_Val = 0x0;
while (1)
{
for(i=0;i<=0x3ff;i++)
{
DAC_Val=i<<6;
DACR=DAC_Val;
}
}
}
#include<LPC214x.H>
int main(void)
{
unsigned int DAC_Val,i,j;
VPBDIV = 0x01;
PINSEL1 = 0x00080000; //ENABLE DAC PIN (P0.25)
DAC_Val = 0x0;
while (1)
{
for(i=0;i<=0x3ff;i++) // for rising slope
{
DAC_Val=i<<6;
DACR=DAC_Val;
}
for(i=0x3ff;i>0;i--) // for falling slope
{
DAC_Val=i<<6;
DACR=DAC_Val;
}
}
}
#include<LPC214x.H>
Unsigned int sample[]={512,528,544,560,576,592,608,624,639,655,670,685,700,715,730,
744,759,773,786,800,813,826,838,850,862,874,885,896,906,916,926,935,944,953,961,968,975,
982,988,994,999,1004,1008,1012,1015,1018,1020,1022,1022,1023,1023,1023,1022,1022,1020,
1018,1015,1012,1008,1004,999,994,988,982,975,968,961,953,945,936,927,917,907,896,886,87
4,863,851,839,826,813,800,787,773,759,745,731,716,701,686,671,656,640,624,609,593,577,56
1,545,529,513,497,481,465,449,433,417,401,386,370,355,339,324,310,295,280,266,252,238,22
5,212,199,186,174,162,151,139,129,118,108,98,89,80,72,64,56,49,43,36,31,25,21,16,13,9,6,4,2,1
,0,0,0,1,2,4,6,9,12,16,20,25,30,35,42,48,55,63,71,79,88,97,107,117,127,138,149,160,172,185,197
,210,223,236,250,264,278,293,307,322,337,352,368,383,399,415,430,446,462,478,494};
int main(void)
{
unsigned int DAC_Val,i;
VPBDIV = 0x01;
PINSEL1 = 0x00080000; //ENABLE DAC PIN (P0.25)
DAC_Val = 0x0;
while (1)
{
for(i=0;i<200;i++)
{
DAC_Val=sample[i]<<6;
DACR=DAC_Val;
}
}
}
Result:
Thus the all waveforms obtained by on chip DAC and verified by DSO.
Experiment No 3
int main()
{
tled = 0x00FF0000; // Define P0.16 – P0.23 as O/P
while(1) // Loop forever
{
led = 0x00AA0000; // Turn ON P0.16 – P0.23
delay(2000);
led = 0x00550000; // Turn OFF P0.16 – P0.23
delay(2000);
}
}
void delay(int x)
{
unsigned int k,l;
for(k = x;k > 0;k--)
for(l = 0;l < x;l++);
}
#include <lpc214x.h>
void PWM_Init()
{
PINSEL0 = 0x00000002; /* set GPIOs for PWM1*/
PWMTCR = 0x00000002; /* Counter Reset */
PWMPR = 0x00000000; /* count frequency:Fpclk */
PWMLER = 0x0000007F; /* all PWM latch enabled */
}
void PWM_Set()
{
PWMMR0 = 2000; // Total count.
PWMMR1 = 1500; // On time count.
}
int main(void)
{
PWM_Init(); /* PWM Init */
PWM_Set(); /* Set % PWM Cycle */
PWM_Start(); /* Start PWM genration */
while(1);
}
Result:
Thus the Toggling LED, Shifting LED and PWM output was verified.
Experiment No 4
void rtc_int(void)__irq
{
ILR = 0x01;
}
int main(void)
{
VPBDIV = 0x02;
DelayMs(1000);
IO0DIR=0x00000700;
IO1DIR=0x00FF0000;
lcd_cmd(0x38);
lcd_cmd(0x0C);
lcd_cmd(0x01);
lcd_cmd(0x06);
lcd_cmd(0x80);
lcd_data_string(arr1);
init_rtc();
while(1)
{ lcd_cmd(0xC4);
lcd_dat(HOUR/10 + '0');
lcd_dat(HOUR%10 + '0');
lcd_dat(':') ;
lcd_dat(MIN/10 + '0');
lcd_dat(MIN%10 + '0');
lcd_dat(':');
lcd_dat(SEC/10 + '0');
lcd_dat(SEC%10 + '0');
}
}
void DelayMs(unsigned int ms)
{
long i,j;
for (i = 0; i < ms; i++ )
for (j = 0; j < 6659; j++ );
}
void busy_check()
{
DelayMs(5);
}
void lcd_cmd(unsigned char value)
{
busy_check();
IO0CLR=RS;
IO0CLR=RW;
lcd_data=(value<<16);
IO0SET=EN;
IO0CLR=EN;
return;
}
void lcd_dat(unsigned char item)
{
busy_check();
IO0SET=RS;
IO0CLR=RW;
lcd_data=(item<<16);
IO0SET=EN;
IO0CLR=EN;
return;
}
void lcd_data_string(unsigned char *str) // Program to send string to LCD
{
int i=0;
while(str[i]!='\0')
{
lcd_dat(str[i]);
i++;
DelayMs(5);
}
return;
}
void init_rtc(void)
{
ILR = 0x01;
CCR = 0x13;
CCR = 0x11;
CIIR = 0x01;
SEC = 0x00;
MIN = 0x00;
HOUR = 0x00;
VICIntEnable |= (1<<13); //RTC Interrupt 13(0x0D)
VICVectCntl0 = 0x0000002D; //0x20+13=0x2D
VICVectAddr0 = (unsigned)rtc_int;
}
Result:
Thus the RTC operation was verified by LCD.
/***********************************************************************************************
* UART0 Initialization
* Description : This function Initializes the UART0.
* Note : This function should be called once before any of the other functions of UART0.
***********************************************************************************************/
void UART0_Init()
{
PINSEL0 = 0x00000005; /* lower 4bit selected for UART0 and remaining all bits selected for
GPIO's.*/
/* frist LSB 2bit(0 and 1 bits) selected 01b for UART0 Tx.*/
/* LSB bit(2 and 3 bits) selected 01b for UART0 Rx.*/
U0LCR = 0x83; /* 0x83: enable Divisor Latch access, set 8-bit word length,no Parity,1 Stop
bit*/
VPBDIV = 0x01; /* VPBDIV: VPB bus clock divider 0x01: PCLK = processor clock*/
/*-----------------------------------------------------------------------------------------------*/
// BAUD RATE CALCULATION
// DIVISOR = (PCLK/(16*DESIRED_BAUDRATE))
// For Example
// Peripheral Clock Frequency (PCLK) = 60 Mhz
// Desired Baud Rate = 9600 bps
// Divisor = (60000000/(16*9600)) = 390(Decimal) =186(Hex)
//-----------------------------------------------------------------------------------------------
U0DLL = 0x86;
U0DLM = 0x01;
U0LCR = 0x03; /* 0x03: same as above, but disable Divisor Latch access.*/
}
/***********************************************************************************************
* Send_Char
* Description : Write a character to Serial Port
***********************************************************************************************/
unsigned char Send_Char(unsigned char ch)
{
if (ch == '\n')
{
while(!(U0LSR & 0x20));
U0THR='\r'; /* output CR */
}
while(!(U0LSR & 0x20));
return (U0THR = ch);
}
/***********************************************************************************************
**
* Main Routine
***********************************************************************************************/
int main (void)
{
int i;
UART0_Init(); /* Init UART 0 */
while (1) /* Infinite Loop */
{
Send_String("IElec Systems.,Nellai\n");
}
}
Result:
Thus the strings write to serial uart-0 and verified by Hyper Terminal.
Experiment No 5
char Newline[]="\n\r";
char TAB[]="\t";
void Delay(unsigned int Time)
{
unsigned int i,j;
for(i=0;i<=Time;i++)
for(j=0;j<110;j++);
}
void UART0_Init()
{
PINSEL0 = 0x05; /* Enable RxD0 and TxD0 */
U0LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
U0DLL = 0x86; /* 9600 Baud Rate @60MHz VPB Clock */
U0DLM = 0x01;
U0LCR = 0x03; /* DLAB = 0 */
VPBDIV = 0x01;
}
Result:
Thus the 4X4 Matrix keypad interface was verified by Hyper Terminal.
void main()
{
IO0DIR=0x00000F00;
IO1DIR=0x00FF0000;
PINSEL0 = 0x00000000;
PINSEL1 = 0x00000000;
PINSEL2 = 0x00000000;
lcd_cmd(0x38);
lcd_cmd(0x0C);
lcd_cmd(0x01);
lcd_cmd(0x06);
lcd_cmd(0x80);
lcd_data_string(arr1);
lcd_cmd(0xc0);
lcd_data_string(arr2);
while(1);
}
Result:
Thus the strings write to 16X2 LCD and Display.
Experiment No 6
void Send_Start()
{
I2C0CONSET=0x20;
}
void Send_Stop()
{
I2C0CONSET=0x10;
}
// This function sends sequential data to the EEPROM 24LC04
// The buffer size for EEPROM 24LC04 is 16 bytes
// The Len parameter should not exceed this value
unsigned char Send_I2C(unsigned char *Data,unsigned char Len)
{
while(Len)
{
I2C0DAT=*Data;
if(I2C_Status(0x28))
{
return 1;
}
Len--;
Data++;
}
return 0;
}
I2C0DAT=BLOCK_ADDR;
if(I2C_Status(0x28)) //Block address has been transmitted
{
return 1;
}
void I2C_Init()
{
PINSEL0&=0xFFFFFF0F;
PINSEL0|=0x00000050;
PINSEL1 = 0;
I2C0CONCLR=0x6C;
I2C0CONSET=0x40;
I2C0SCLH =80;
I2C0SCLL =70;
int main(void)
{
IO1DIR &= 0xfC7fffff;
IO0DIR &= 0xfff8ffff;
UART0_Init(9600);
I2C_Init();
UART0_puts ("********* ARM7/LPC-2148 I2C EEPROM Demo **********\n\r");
UART0_puts (">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\r");
UART0_puts ("[~] Turn SW 1 ON to Write default data to EEPROM! \n\r");
UART0_puts ("[~] Turn SW 2 ON to Read and Display data from EEPROM! \n\r");
UART0_puts ("[~] Turn SW 3 ON to Erase data from EEPROM \n\r");
while(1)
{
if ((IOPIN0 & SW1) == 0) /*...To Load the Default Data to the EEPROM ...*/
{
if(Page_Write(BLK_1,0x00,I2C_WR_Buf))
{
UART0_puts("Write Failed");
}
Delay(50);
UART0_puts("Data Written Successfully\r\n");
while (!(IOPIN0 & SW1));
}
else if ((IOPIN0 & SW2) == 0) /*..To Read the Data Stored in the EEPROM...*/
{
if(Page_Read(BLK_1,0x00))
{
UART0_puts("Read Failed");
}
else
{
UART0_puts("Data Read:");
UART0_puts(I2C_RD_Buf);
UART0_puts("\r\n");
}
Delay(50);
while (!(IOPIN0 & SW2));
}
else if ((IOPIN0 & SW3) == 0)
{
if(Page_Write(BLK_1,0x00,I2C_ER_Buf))
{
UART0_puts("Write Failed");
}
Delay(50);
UART0_puts("Data Erase Successfully\r\n");
while (!(IOPIN0 & SW3));
}
}
}
Result:
Thus the strings Erase, write and Read to I2C EPROM.
void InitExtInt0(void)
{
VICVectCntl0 = (1<<5) | 14; /* use it for External Interrupt 0 */
VICIntEnable = (1<<14); /* Enable External Interrupt0 */
VICVectAddr0 = (unsigned long)ExtInt0_ISR; /* set interrupt vector in 0 */
}
int main(void)
{
PINSEL0 = 0x0000000C; /*Enable the EXTINT0 interrupt */
PINSEL2 = 0x00000000; /* Select pin for LED I/F */
IO1DIR = 0x00FF0000; /* Set direction for Pin P1.16 to Pin P1.23 as output */
VPBDIV = 0x00000001;
InitExtInt0(); /* Init Extenal Interrupt 0 */
while(1)
{
IO1CLR = 0x00FF0000; /* Clear All LED */
}
}
Result:
Thus the External Interrupt0 activated by level triggered switch and Interrupt Service Routine (ISR) was
executed and output was observed by LED.
Experiment No 7
7. MAILBOX.
Aim of the Experiment:
To write the program for Mailbox using Keil-RTX kernal.
/*----------------------------------------------------------------------------
* RL-ARM - RTX
*----------------------------------------------------------------------------
* Name: MAILBOX.C
* Purpose: RTX example program
*----------------------------------------------------------------------------
* This code is part of the RealView Run-Time Library.
* Copyright (c) 2004-2013 KEIL - An ARM Company. All rights reserved.
*---------------------------------------------------------------------------*/
} T_MEAS;
/*----------------------------------------------------------------------------
* Initialize serial interface
*---------------------------------------------------------------------------*/
void init_serial () {
PINSEL0 = 0x00000005; /* Enable RxD0 and TxD0 */
U0LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
U0DLL = 97; /* 9600 Baud Rate @ 15MHz VPB Clock */
U0LCR = 0x03; /* DLAB = 0 */
}
/*----------------------------------------------------------------------------
* Task 1: RTX Kernel starts this task with os_sys_init (send_task)
*---------------------------------------------------------------------------*/
__task void send_task (void) {
T_MEAS *mptr;
for (;;)
{
os_mbx_wait (MsgBox, (void **)&rptr, 0xffff); /* wait for the message */
printf ("\nVoltage: %.2f V\n",rptr->voltage);
printf ("Current: %.2f A\n",rptr->current);
printf ("Number of cycles: %d\n",rptr->counter);
_free_box (mpool, rptr); /* free memory allocated for message */
}
}
/*----------------------------------------------------------------------------
* Main: Initialize and start RTX Kernel
*---------------------------------------------------------------------------*/
int main (void) { /* program execution starts here */
init_serial (); /* initialize the serial interface */
_init_box (mpool, sizeof(mpool), /* initialize the 'mpool' memory for */
sizeof(T_MEAS)); /* the membox dynamic allocation */
os_sys_init (send_task); /* initialize and start task 1 */
}
Result:
Thus the mail massage has been sent and received by Hyper Terminal using Keil-RTX Kernel.
Experiment No 9
9. FLASHING OF LEDS.
Aim of the Experiment:
To write the program for flashing of LEDS.
int main(void)
{
tled = 0x00FF0000; // Define P0.16 – P0.23 as O/P
{
led = 0x00FF0000; // Turn ON P0.16 – P0.23
delay(2000);
led = 0x00000000; // Turn OFF P0.16 – P0.23
delay(2000);
}
}
void delay(int x)
{
unsigned int k,l;
for(k = x;k > 0;k--)
for(l = 0;l < x;l++);
}
Result:
Thus the Flashing LEDs program was written and executed. Output was verified.
Experiment No 10
}
void delay(int x)
{
unsigned int k,l;
for(k = x;k > 0;k--)
for(l = 0;l < x;l++);
}
Result:
Thus the following Stepper Motor programs was written and executed. Output was verified.
/***********************************************************************************************
* ADC initialization *
***********************************************************************************************/
void ADC_Init()
{
PINSEL1 = 0x01000000; /* channel AD0.1 (P0.28) */
AD0CR = 0x00230602; /* Setup A/D: 10-bit AIN0 @ 3MHz */
}
Used Formula:
Digital O/P = Analag I/P X 2n /Vref
Temperature =Digital O/P x 0.322
Where,
N = No of bits per ADC(1024).
Vref =Refernce Voltage(3.3V)
Result:
Thus the Temp program was written and find the room temparature and display by Hyper Teriminal.
Experiment No 11
Used Formula:
Digital O/P = Analag I/P X 2n /Vref
Temperature =Digital O/P x 0.322
Where,
N = No of bits per ADC(1024).
Vref =Refernce Voltage(3.3V)
Result:
Thus the Temp program was written and find the room temparature and sent to PC by wireless ZigBee
Co-ordinator & Router. Output verified by Hyper Teriminal.