Development of The ARM Architecture
Development of The ARM Architecture
Architecture
ARM has introduced many processors. Each set or groups of processors
are having different core and different Features. Development of the ARM
Architecture is started with 26 bit processors and nowadays it reach upto
64 bit. we can not classify general development of ARM products on any
particular fact, there is only one way to understand ARM based products is
on its Architectural version profile.
This is Cortex architecture which mostly used for real time purpose where
application abort is critical situation contain core features like Protected
memory (MPU), Low latency and predictability real-time needs.
Processor Modes
All these mode indicates its special work and execute under certain
condition with its own stack and a different subset of registers. Modes
other than User mode are collectively known as privileged modes. your
program or application generally runs under User mode. Privileged modes
are used to service interrupts or exceptions, or to access protected
resources.
Current/State Program
Status Register (CPSR /
SPSR)
T Bit (Bit 5)
Introduced in Architecture 4T
Mode bits (Bit 0 to 4)
I = 1: Disables IRQF = 1:
Disables FIQ
groups
SUB r0,r1,#5
r0 = r1 5
ADD r2,r3,r3,LSL #2
r2 = r3 + (r3 * 4)
ADDEQ r5,r5,r6
IF EQ condition true r5 = r5 + r6
B <Label>
LDR r0,[r1]
STRNEB r2,[r3,r4]
STMFD sp!,{r4-r8,lr}
and
ALU
Exception Handling
Terms
ARM
associated
with
EmbeddedICE
In order to provide a powerful debugging environment for ARM-based
applications the EmbeddedICE logic was developed and integrated into
the ARM core architecture. It is a set of registers providing the ability to
set hardware breakpoints or watch-points on code or data.
The EmbeddedICE logic monitors the ARM core signals every cycle to
check
if
a
break-point
or watch-point
has
been
hit.
Communication with the EmbeddedICE logic from the external
world is provided via the test access port or TAP, controller and a standard
IEEE 1149.1 JTAG connection. The advantage of on-chip debug solutions is
the ability to rapidly debug software, especially when the software resides
in ROM or Flash.
AMBA Bus
The Advanced Micro-controller Bus Architecture on-chip bus is freely
available from ARM and offers an established, open specification that
serves as a framework for SoC designs.
Reference www.arm.com
The design of the AMBA bus specification is focused on low power
consumption and high performance. A typical AMBA-based SoC consists of
an advanced high-performance system bus(AHB), and an advanced low
power peripheral bus(APB). As seen in above pic
On the performance critical side of the bus is the ARM core, Memory
Controller, Test Interface Controller (TIC), the LCD Controller, on-chip IP,
custom logic, and specialized functions.
On the low power side of the bus is the Smart Card interface, audio
MMU
The Memory Management Unit works with the cache memory system to
control accesses to and from external memory. The MMU also controls the
translation of Virtual Addresses to physical addresses and access
MPU
A separate Memory Protection Unit feature has been introduced in ARM
by Cortex-M3 cores which provide a way to control memory access rights
to applications. This prevents a bug within a process from affecting other
processes, or the operating system itself, and instead results in a
segmentation fault or storage violation exception, generally causing
termination of the process. In ARM core, separate registers are provided
by which you can configure certain portion of memory and its access
rights.
Features of LPC2148
operation.
In-System/In-Application Programming (ISP/IAP) via on-chip boot-
loader software.
Embedded ICE RT and Embedded Trace interfaces offer real-time
debugging with the on-chip Real Monitor software and high speed
tracing of instruction execution.
USB 2.0 Full Speed compliant Device Controller with 2 KB of
four compare channels each), PWM unit (six outputs) and watchdog.
Low power real-time clock with independent power and dedicated
I2C-bus(400 kbps), SPI and SSP with buffering and variable data length
capabilities.
Vectored interrupt controller with configurable priorities and vector
addresses.
Up to 45 of 5 V tolerant fast general purpose I/O pins in a tiny
LQFP64 package.
Up to nine edge or level sensitive external interrupt pins available.
Power saving modes include Idle and Power-down.
Processor wake-up from Power-down mode via external interrupt,
ARM identification
ARM 7 modes
1.
2.
for(i=0;i<1000;i++)
for(j=0;j<1000;j++);
}
IO0SET =ar[i];
delay();
IO0CLR =ar[i];
}
}
return 0;
}
void delay()
{
for(j=0;j<1000;j++)
for(k=0;k<400;k++);
}
#include<lpc21xx.h>
#define
#define
#define
#define
void
void
void
void
LCD (0xff<<16)
RS (1<<13)
RW (1<<14)
EN (1<<15)
int main()
{
PINSEL0=0X00000000;
IO0DIR=0XFFFFFFFF;
lcd_ini();
while(1)
{
lcd_ini();
lcd_display(' ');
lcd_display('W');
delay_fv(1000,400);
lcd_display('E');
delay_fv(1000,400);
lcd_display('L');
delay_fv(1000,400);
lcd_display('C');
delay_fv(1000,400);
lcd_display('O');
delay_fv(1000,400);
lcd_display('M');
delay_fv(1000,400);
lcd_display('E');
delay_fv(1000,400);
lcd_display(' ');
delay_fv(1000,400);
lcd_display('T');
delay_fv(1000,400);
lcd_display('O');
delay_fv(1000,400);
cmd(0x0c0);
lcd_display('F');
delay_fv(1000,400);
lcd_display('I');
delay_fv(1000,400);
lcd_display('R');
delay_fv(1000,400);
lcd_display('M');
delay_fv(1000,400);
lcd_display('C');
delay_fv(1000,400);
lcd_display('O');
delay_fv(1000,400);
lcd_display('D');
delay_fv(1000,400);
lcd_display('E');
delay_fv(1000,400);
lcd_display('S');
delay_fv(1000,400);
lcd_display('.');
delay_fv(1000,400);
lcd_display('C');
delay_fv(1000,400);
lcd_display('O');
delay_fv(1000,400);
lcd_display('M');
delay_fv(1000,400);
}
}
void delay_fv(unsigned int x,int y)
{
unsigned int i,j;
for(i=0;i<x;i++)
for(j=0;j<y;j++);
}
void lcd_display(unsigned int x)
{
IO0CLR|=(RS|RW|EN|LCD);
IO0SET|=(x<<16);
IO0SET|=RS;
IO0CLR|=RW;
IO0SET|=EN;
delay_fv(100,10);
IO0CLR|=EN;
delay_fv(10,10);
}
void cmd(unsigned char m)
{
IO0CLR|=(RS|RW|EN|LCD);
IO0SET|=(m<<16);
IO0CLR|=RS;
IO0CLR|=RW;
IO0SET|=EN;
delay_fv(100,100);
IO0CLR|=EN;
delay_fv(100,10);
}
void lcd_ini()
{
cmd(0X38);
cmd(0X0e);
cmd(0X06);
cmd(0X01);
cmd(0X80);
}
#include<lpc21xx.h>
#define switch_1 (IO0PIN&0X01)
#define led (0xff<<1)
void delay();
int main()
{
PINSEL0=0X00000000;
IO0DIR=0Xfffffffe;
IO0CLR=led;
while(1)
{
if(switch_1==1)
{
IO0SET=led;
delay();
IO0CLR=led;
delay();
}
}
}
void delay()
{
int i,j;
for(i=0;i<100;i++)
for(j=0;j<600;j++);
}
int i,j;
for(i=0;i<100;i++)
for(j=0;j<600;j++);
}
#include<lpc21xx.h>
unsigned char rec;
void pll();
void serial_ini();
void serial_transmit(unsigned char x);
void delay(int x);
int main()
{
PINSEL0 = 0x00000005;
IO0DIR=0XFFFFFFFF;
serial_ini();
pll();
while(1)
{
}
/* SERIAL INITILIZATION*/
void serial_ini()
{
U0LCR =0x83;
U0DLM=0X00;
U0DLL=0X5e;
U0FDR=0X52;
U0LCR =0x03;
}
void serial_transmit(unsigned char x)
{
U0THR =x;
// LOAD DATA IN U0THR REGISTER
while ((U0LSR & 0x40)==0); // WAIT FOR DATA TRANSMISSION
U0LSR|=0X40;
}
void delay(int x)
{
int i,j;
x=x*10;
for(i=0;i<x;i++)
for(j=0;j<350;j++);
}
#include<lpc21xx.h>
#define
#define
#define
#define
LCD (0xff<<16)
RS (1<<13)
RW (1<<14)
EN (1<<15)
pll();
lcd_ini();
while(1)
{
serial_re();
lcd_display(rec);
}
}
void delay_fv(unsigned int x,int y)
{
unsigned int i,j;
for(i=0;i<x;i++)
for(j=0;j<y;j++);
}
void lcd_display(unsigned int x)
{
IO0CLR|=(RS|RW|EN|LCD);
IO0SET|=(x<<16);
IO0SET|=RS;
IO0CLR|=RW;
IO0SET|=EN;
delay_fv(100,10);
IO0CLR|=EN;
delay_fv(10,10);
}
void cmd(unsigned char m)
{
IO0CLR|=(RS|RW|EN|LCD);
IO0SET|=(m<<16);
IO0CLR|=RS;
IO0CLR|=RW;
IO0SET|=EN;
delay_fv(100,100);
IO0CLR|=EN;
delay_fv(100,10);
}
void lcd_ini()
{
cmd(0X38);
cmd(0X0e);
cmd(0X06);
cmd(0X01);
cmd(0X80);
}
void pll()
{
/*PLL IS CONFIGURED TO GET 60HZ pCLK*/
PLLCFG=0X24;
// SET PSEL=2 AND MSEL=5
PLLCON=0X01;
//PLL IS ACTIVE BUT NOT YET CONNECT
PLLFEED=0XAA;
//FEED SEQUENCE
PLLFEED=0X55;
//FEED SEQUENCE
while((PLLSTAT & 0X400)==0); //WAIT FOR FEED SEQUENCE TO BE
INSERTED
PLLCON=0X03;
// PLL HAS BEEN ACTIVE AND BEING CONNECTRD
VPBDIV=0X00;
// SET PCLK SAME AS FCCLK
PLLFEED=0XAA;
//FEED SEQUENCE
PLLFEED=0X55;
//FEED SEQUENCE
}
void serial_ini()
{
U0LCR =0x83;
U0DLM=0X00;
U0DLL=0X5e;
U0FDR=0X52;
U0LCR =0x03;
}
char serial_re()
{
while ((U0LSR & 0x01)==0); // wait untill complete data is received
rec=U0RBR;
return rec;
}
#include<lpc21xx.h>
# define PRESCALAR 60000
void pll();
void timer0_ini();
void delay(unsigned long int ms);
int main()
{
PINSEL0=0x00000000; // select gpio pin
IO0DIR=0XFFFFFFFF; // make gpio as output pin
pll();
// calling pll function
timer0_ini();
// calling timer function
while(1)
{
IO0SET=0XFFFFFFFF; // led on
delay(0x000000fF); // delay using timer 0
IO0CLR=0XFFFFFFFF; // led off
delay(0x000000fF); // delay using timer 0
}
return 0;
}
void pll()
{
//PLL IS CONFIGURED TO GET 60HZ pCLK
PLLCFG=0X24;
// SET PSEL=2 AND MSEL=5
PLLCON=0X01;
//PLL IS ACTIVE BUT NOT YET CONNECT
PLLFEED=0XAA;
//FEED SEQUENCE
PLLFEED=0X55;
//FEED SEQUENCE
while((PLLSTAT & 0X400)==0); //WAIT FOR FEED SEQUENCE
TO BE INSERTED
PLLCON=0X03;
// PLL HAS BEEN ACTIVE AND BEING
CONNECTRD
VPBDIV=0X00;
// SET PCLK SAME AS FCCLK
PLLFEED=0XAA;
//FEED SEQUENCE
PLLFEED=0X55;
//FEED SEQUENCE
}
void timer0_ini()
{
T0TCR=0X0; // to stop timer
T0PR=PRESCALAR-1; //load the timer value
T0TCR=0X02;
//reset timer
}
void delay(unsigned long int ms)
{
T0TC=0x00000000; // t0 reset timer counting
T0TCR=0X02; // reset the timer
T0TCR=0X01; // start timer
while(T0TC<=ms); // check the condition
SQUARE WAVE
#include<lpc21xx.h>
# define PRESCALAR 60000
void pll();
void timer0_ini();
void delay(unsigned long int ms);
int main()
{
PINSEL0=0x00000000; // select gpio pin
IO0DIR=0XFFFFFFFF; // make gpio as output pin
pll();
// calling pll function
timer0_ini();
// calling timer function
while(1)
{
IO0SET=0X01; // high level
delay(0x0000000F); // delay using timer 0
IO0CLR=0X01; // low level
delay(0x0000000F); // delay using timer
0
}
return 0;
}
void pll()
{
//PLL IS CONFIGURED TO GET 60HZ pCLK
PLLCFG=0X24;
// SET PSEL=2 AND MSEL=5
PLLCON=0X01;
//PLL IS ACTIVE BUT NOT YET CONNECT
PLLFEED=0XAA;
//FEED SEQUENCE
PLLFEED=0X55;
//FEED SEQUENCE
while((PLLSTAT & 0X400)==0); //WAIT FOR FEED SEQUENCE TO BE
INSERTED
PLLCON=0X03;
VPBDIV=0X00;
PLLFEED=0XAA;
PLLFEED=0X55;
CONNECTRD
}
void timer0_ini()
{
T0TCR=0X0; // to stop timer
T0PR=PRESCALAR-1; //load the timer value
T0TCR=0X02;
//reset timer
}
void delay(unsigned long int ms)
{
T0TC=0x00000000; // t0 reset timer counting
T0TCR=0X02; // reset the timer
T0TCR=0X01; // start timer
while(T0TC<=ms); // check the condition
T0TCR=0X00; // stop timer
}
#include<lpc213x.h>
#define
#define
#define
#define
LCD (0xff<<16)
RS (1<<13)
RW (1<<14)
EN (1<<15)
IO0CLR|=RW;
IO0SET|=EN;
delay_fv(100,200);
IO0CLR|=EN;
delay_fv(10,10);
}
void cmd(unsigned char m)
{
IO0CLR|=(RS|RW|EN|LCD);
IO0SET|=(m<<16);
IO0CLR|=RS;
IO0CLR|=RW;
IO0SET|=EN;
delay_fv(100,10);
IO0CLR|=EN;
delay_fv(100,10);
}
void lcd_ini()
{
cmd(0X38);
cmd(0X0e);
cmd(0X06);
cmd(0X01);
cmd(0X80);
}
void lcd_pos(int line, int pos)
{
if(line==1)
cmd(0x80+pos);
else if(line==2)
cmd(0xc0+pos);
}
void lcd_str(unsigned char *x)
{
while(*x!='\0')
{
lcd_display(*x);
x++;
}
}
void pll()
{
/*PLL IS CONFIGURED TO GET 60HZ pCLK*/
PLLCFG=0X24;
// SET PSEL=2 AND MSEL=5
PLLCON=0X01;
//PLL IS ACTIVE BUT NOT YET
CONNECT
PLLFEED=0XAA;
PLLFEED=0X55;
//FEED SEQUENCE
//FEED SEQUENCE
void adc_ini()
{
AD0CR = 1<<21; //A/D is Operational
AD0CR = 0<<21; //A/D is in Power Down Mode
PINSEL1 = 0x01000000;//P0.28 is Configured as Analog to Digital
Converter Pin AD0.1
AD0CR = 0x00200802; //CLKDIV=4,Channel-0.1
Selected,BURST=0,EDGE=0
/*PDN=0
A/D Clock = PCLK /(CLKDIV+1);*/
}
unsigned long int adc_data()
{
unsigned long rec;
AD0CR |= (1<<24);
//Start Conversion
while(!(AD0GDR & 0x80000000));
/*Wait untill the DONE bits Sets*/
rec = AD0GDR;
AD0CR &= ~0x01000000;
//Stops the A/D
Conversion
rec = rec >> 6; // data is present after 6 bit
rec = rec & 0x3FF; //Clearing all other Bits
return (rec);
}
www.firmcodes.com
DEVELOPED BY:- FIRMWARE DEVELOPER
WHAT PROGRAM DO:- Program Of Multiplex 8 Seven Segment Using
Max7221 And Controlled With ARM(LPC21XX) Using SPI Protocol
******************************************************/
#include<lpc21xx.h>
unsigned char spi_rec;
void spi_ini();
void spi_tr1(unsigned int x);
char spi_re();
void spi_tr(unsigned char cmd,unsigned char data);
void spi_str(unsigned char *str);
int ar[10]={ 0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f };
int ar1[8]={0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08};
void pll();
void delay_ms(unsigned int x);
int main()
{
int i,a,b,c,d,e,f,g,h;
a=b=c=d=e=f=g=h=0;
PINSEL0=0X00000000;
IO0DIR=0XFFFFFFFF;
pll();
spi_ini();
spi_tr(0x0a,0xf);
spi_tr(0x0b,0xf);
for(i=0;i<9;i++)
{
spi_tr(ar1[i],ar[0]);
delay_ms(100);
}
spi_tr(0x0c,0x01);
while(1)
{
spi_tr(ar1[7],ar[a]);
spi_tr(ar1[6],ar[b]);
spi_tr(ar1[5],ar[c]);
spi_tr(ar1[4],ar[d]);
spi_tr(ar1[3],ar[e]);
spi_tr(ar1[2],ar[f]);
spi_tr(ar1[1],ar[g]);
spi_tr(ar1[0],ar[h]);
a++;
if(a==10)
{
a=0;
b++;
}
if(b==10)
{
a=b=0;
c++;
}
if(c==10)
{
a=b=c=0;
d++;
}
if(d==10)
{
a=b=c=d=0;
e++;
}
if(e==10)
{
a=b=c=d=e=0;
f++;
}
if(f==10)
{
a=b=c=d=e=f=0;
g++;
}
if(g==10)
{
a=b=c=d=e=f=g=0;
h++;
}
if(h==10)
{
a=b=c=d=e=f=g=h=0;
}
delay_ms(3000);
}
}
void pll()
{
/*PLL IS CONFIGURED TO GET 60HZ pCLK*/
PLLCFG=0X24;
// SET PSEL=2 AND MSEL=5
PLLCON=0X01;
//PLL IS ACTIVE BUT NOT YET
CONNECT
PLLFEED=0XAA;
//FEED SEQUENCE
PLLFEED=0X55;
//FEED SEQUENCE
while((PLLSTAT & 0X400)==0); //WAIT FOR FEED SEQUENCE
TO BE INSERTED
PLLCON=0X03;
VPBDIV=0X00;
PLLFEED=0XAA;
PLLFEED=0X55;
CONNECTRD
}
void spi_ini()
{
PINSEL0 |=0x1500;
/* P0.4, P0.5, P0.6, P0.7 are set as SCK,
MISO, MOSI and GPIO */
//IODIR0 |= 0X80;
/* SSEL is output */
//IOSET0 |=0X80;
/* set SSEL to high */
S0SPCCR=8;
/* SPI clock
prescale register minimum value is 8. */
S0SPCR=0x0030;
/* Device select as
master, Set data to 8-bit, CPOL = 0, CPHA = 0*/
}
void spi_tr1(unsigned int x)
{
S0SPDR =x;
while ( !(S0SPSR & 0x80) );
trabsfer complete */
}
char spi_re()
{
while ( !(S0SPSR & 0x80) );
trabsfer complete */
spi_rec= S0SPDR;
return spi_rec;
}
#include<lpc21xx.h>
#define
#define
#define
#define
LCD (0xff<<16)
RS (1<<13)
RW (1<<14)
EN (1<<15)
lcd_ini();
init_rtc();
lcd_str("CLOCK:- 24");
cmd(0xc0);
lcd_str("00:00:00");
while(1)
{
if(flag)
{
flag=0;
lcd_pos(2,0);
lcd_display(HOUR/10 + '0');
lcd_display(HOUR%10 + '0');
lcd_display(':') ;
lcd_display(MIN/10 + '0');
lcd_display(MIN%10 + '0');
lcd_display(':') ;
lcd_display(SEC/10 + '0');
lcd_display(SEC%10 + '0');
}
}
}
void delay_fv(unsigned int x,int y)
{
unsigned int i,j;
for(i=0;i<x;i++)
for(j=0;j<y;j++);
}
void lcd_display(unsigned int x)
{
IO0CLR|=(RS|RW|EN|LCD);
IO0SET|=(x<<16);
IO0SET|=RS;
IO0CLR|=RW;
IO0SET|=EN;
delay_fv(100,10);
IO0CLR|=EN;
delay_fv(10,10);
}
void cmd(unsigned char m)
{
IO0CLR|=(RS|RW|EN|LCD);
IO0SET|=(m<<16);
IO0CLR|=RS;
IO0CLR|=RW;
IO0SET|=EN;
delay_fv(100,250);
IO0CLR|=EN;
delay_fv(10,10);
}
Interrupts on ARM7:
PINSEL2=0X00000000;
mode
mode
IO0DIR=0X0fFFFFFF;
// direction of port0.0 to port0.31 worked
as output mode
IO1DIR=0XFFFFFFFF;
// direction of port1.0 to port1.31 worked
as output mode
lcd_ini();
// lcd initilization function
interrupt_ini();
// interrupt intilization function
while(1)
{
IO1SET|=(ar[count]<<16);
delay_fv(1000,1000);
IO1CLR|=(ar[count]<<16);
count++;
if(count==10)
count=0;
}
return 0;
}
void interrupt_0()__irq // interrupt 0
{
EXTINT=0X01;
IO0SET|=(0XFF<<16);
delay_fv(500,1000);
IO0CLR|=(0XFF<<16);
delay_fv(500,1000);
}
void interrupt_1()__irq // interrupt 1
{
EXTINT=0X02;
cmd(0x01);
lcd_str("WELCOME TO");
cmd(0xc0);
lcd_str("FIRMCODES.COM");
delay_fv(1000,1000);
}
void interrupt_ini()
{
/* intialize interrupt 0*/
PINSEL0|=0x0c;
VICVectAddr0=(unsigned)interrupt_0;
VICVectCntl0=0x20|14;
VICIntEnable=1<<14;
// delay_fv(1000,100);
/* intialize interrupt 1*/
PINSEL0|=0xc0;
VICVectAddr1=(unsigned)interrupt_1;
VICVectCntl1=0x20|15;
VICIntEnable=1<<15;
}
DELAY.H HEADER FILE
***********************************************************************/
void delay_ff()
{
delay_fv(10,10);
IO0CLR|=(RS|RW|EN|LCD);
temp=x&0x0f;
//delay_ms(1000);
IO0SET|=RS;
IO0CLR|=RW;
IO0SET|=EN;
IO0CLR|=LCD;
IO0SET|=(temp<<11);
delay_ms(100);
IO0CLR|=EN;
delay_ms(100);
}
void cmd(unsigned char x)
{
unsigned int temp;
delay_ms(100);
temp=(x>>4)&0x0f;
IO0CLR|=(RS|RW|EN);
IO0CLR|=RS;
IO0CLR|=RW;
IO0SET|=EN;
IO0CLR|=LCD;
IO0SET|=(temp<<11);
delay_ms(100);
IO0CLR|=EN;
delay_fv(100,10);
IO0CLR|=(RS|RW|EN);
temp=x&0x0f;
IO0SET|=(temp<<11);
IO0CLR|=RS;
IO0CLR|=RW;
IO0SET|=EN;
IO0CLR|=LCD;
IO0SET|=(temp<<11);
delay_ms(100);
IO0CLR|=EN;
delay_fv(100,100);
}
void lcd_ini()
{
PINSEL0|=(0XFF<<8);
IO0DIR|=(0XF<<8);
cmd(0X02);
cmd(0X28);
// cmd(0X02);
cmd(0x0e);
cmd(0X06);
cmd(0X01);
cmd(0X80);
}