Thursday, 9 June 2016

Interfacing of seven segment with LPC2148

SEVEN SEGMENT: 
 Seven segment display (SSD), or seven-segment indicator, is a form of electronic display device for displaying decimal numerals  that is an alternative to the more complex dot matrix displays.
 seven segment display consists of seven LEDs (hence its name) arranged in a rectangular fashion as shown. Each of the seven LEDs is called a segment because when illuminated the segment forms part of a numerical digit (both Decimal and Hex) to be displayed. An additional 8th LED is sometimes used within the same package thus allowing the indication of a decimal point, (DP) when two or more 7-segment displays are connected together to display numbers greater than ten.



                                                                  





Each one of the seven LEDs in the display is given a positional segment with one of its connection pins being brought straight out of the rectangular plastic package. These individually LED pins are labelled from a through to g representing each individual LED. The other LED pins are connected together and wired to form common pin.
       So by forward biasing the appropriate pins of the LED segments in a particular order, some segments will be light and others will be dark allowing the desired character pattern of the number to be generated on the display. This then allows us to display each of the ten decimal digits 0 through to 9 on the same 7-segment display. The displays common pin is generally used to identify which type of 7-segment display it is. As each LED has two connecting pins, one called the “Anode” and the other called the “Cathode”.

There are two types of seven segments:

1) Common Cathode
2) Common Anode
1)  Common Cathode:   In the common cathode display, all the cathode connections of the LED segments are joined together to logic 0 or ground. The individual segments are illuminated by application of a HIGH, or logic 1 signal via a current limiting resistor to forward bias the individual Anode terminals (a-g).


                                    




2)  Common Anode
 In the common anode display, all the anode connections of the LED segments are joined together to logic “1”. The individual segments are illuminated by applying a ground, logic “0” or “LOW” signal via a suitable current limiting resistor to the Cathode of the particular segment (a-g).



                                  




PIN Diagram of 7 segment:





7 Segment Display Segments for all Numbers:








Hexadecimal encodings for 7 Segment common cathode:



Digit
gfedcba
abcdefg
a
b
c
d
e
f
g
0
0×3F
0×7E
on
on
on
on
on
on
off
1
0×06
0×30
off
on
on
off
off
off
off
2
0×5B
0×6D
on
on
off
on
on
off
on
3
0×4F
0×79
on
on
on
on
off
off
on
4
0×66
0×33
off
on
on
off
off
on
on
5
0×6D
0×5B
on
off
on
on
off
on
on
6
0×7D
0×5F
on
off
on
on
on
on
on
7
0×07
0×70
on
on
on
off
off
on
off
8
0×7F
0×7F
on
on
on
on
on
on
on
9
0×6F
0×7B
on
on
on
on
off
on
on
A
0×77
0×77
on
on
on
off
on
on
on
b
0×7C
0×1F
off
off
on
on
on
on
on
C
0×39
0×4E
on
off
off
on
on
on
off
d
0×5E
0×3D
off
on
on
on
on
off
on
E
0×79
0×4F
on
off
off
on
on
on
on
F
0×71
0×47
on
off
off
off
on
on
on




Hexadecimal encodings for 7 Segment common anode:





Interfacing of seven  segment with LPC2148:

 
C Code: for 0-9

 #include<lpc214x.h>
void delay(int );
int i;
unsigned char a[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
int main()
{
    IO0DIR=IO0DIR|0xff;
    while(1)
    {
        for(i=0;i<=9;i++)
        {
            IO0SET=IO0SET|a[i];
            delay(1000);
            IO0CLR=IO0CLR|a[i];
        }
    }
    return 0;
}

void delay(int k)
{
    int i,j;
    for(i=0;i<k;i++)
    for(j=0;j<=1000;j++);
}



Simulation of seven segments:




 C Code: for 0-99:

#include<lpc21xx.h>

void delay(unsigned int c)
{unsigned int a;
for(a=1;a<=60000;a++);}

int main()
{
    PINSEL0=0x00000000;
    PINSEL1=0x00000000;
    PINSEL2=0x00000000;
  IO0DIR|=0xffffffff;
while(1)
{ unsigned  long int j;
    int i,a[]={0x3f,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
   
   
for(j=0;j<10;j++)
{ IO0SET=IO0SET|a[j];
    for(i=0;i<10;i++)
    {
    IO0SET= IO0SET|(a[i]<<8);
       
        delay(100000);
        IO0CLR= IO0CLR|(a[i]<<8);
    }
    IO0CLR=a[j];
   
}
}
}


 


 C Code: for 0-999:

#include<lpc21xx.h>

void delay(unsigned int c)
{unsigned int a;
for(a=1;a<=60000;a++);}

int main()
{
    PINSEL0=0x00000000;
    PINSEL1=0x00000000;
    PINSEL2=0x00000000;
  IO0DIR|=0xffffffff;
while(1)
{ unsigned  long int j,k;
    int i,a[]={0x3f,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
   
   
for(j=0;j<10;j++)
{ IO0SET=IO0SET|a[j];
    for(i=0;i<10;i++)
    {
    IO0SET= IO0SET|(a[i]<<8);
        for(k=0;k<=9;k++)
{        IO0SET= IO0SET|(a[k]<<16);
        delay(100000);
    IO0CLR= IO0CLR|(a[k]<<16);
}
        IO0CLR= IO0CLR|(a[i]<<8);
    }
    IO0CLR=a[j];
   
}
}
}

 


 C Code: for 0-99: using multiplexing


 #include<lpc21xx.h>

void delay(unsigned int c)
{unsigned int a;
for(a=1;a<=60000;a++);}

int main()
{
    PINSEL0=0x00000000;
    PINSEL1=0x00000000;
    PINSEL2=0x00000000;
  IO0DIR|=0xffffffff;
while(1)
{
    int i,a[]={0x13f,0x106,0x15B,0x14F,0x166,0x16D,0x17D,0x107,0x17F,0x16F};
    int j,b[]={0x23f,0x206,0x25B,0x24F,0x266,0x26D,0x27D,0x207,0x27F,0x26F};
   
for(j=0;j<10;j++)
{
    for(i=0;i<10;i++)
    { IO0SET=a[i];
        delay(100000);
        IO0CLR=a[i];
       
       
    IO0SET=b[j];
        delay(100000);
delay(100000);   
    delay(100000);
        delay(100000);

        IO0CLR=b[j];

}}
}}
 

Interfacing of Led with LPC2148

Led (  Light emitting diode) : Light Emitting Diodes are the mostly commonly used components in many applications. They are made of semiconducting material. This article describes about basic interfacing of LEDs to the 8051 family microcontrollers.


Interfacing of led with LPC2148:


Circuit diagram for blinking a led:




Program for blinking a led:

1) C code:

#include<lpc214x.h>
void delay(int );
int i;
int main()
{
   
    PINSEL0=PINSEL1=PINSEL2=0;
    IO0DIR=0XFFFFFFFF;
   
    while(1)
    {
        IO0SET=IO0SET|(1<<0);
        delay(4000);
        IOCLR=IO0CLR|(1<<0);
        delay(4000);

    IO0SET=IO0SET|(1<<1);
        delay(4000);
        IOCLR=IO0CLR|(1<<1);
        delay(4000);
    }
    return 0;
}

void delay(int k)
{
    int i,j;
    for(i=0;i<k;i++)
    for(j=0;j<=1000;j++);
}



Simulation of led:



 

ARM (LPC2148 microcontroller)


Why beginning with LPC2148 to start ARM :

ARM7 is greatest success family in embedded system application. So here we learn ARM7TDMI based NXPs controller.
ARM7 is balance between new Cortex series and old start up. it is neither too old technology nor latest
ARM7 family is excellent for beginners as per my opinion, because it gives real depth idea about hardware and software implementation & integration by using appropriate IDE.

Features of LPC2148:

* LPC2148 is the widely used IC from ARM-7 family. It is manufactured by Philips (NXP) and it is pre-loaded with many inbuilt peripherals making it more efficient and a reliable option for the beginners as well as high end application developer.
* 8 to 40 kB of on-chip static RAM
*  32 to 512 kB of on-chip flash program memory.
* 128 bit wide interface/accelerator enables high speed 60 MHz 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 endpoint RAM. In addition, the LPC2146/8 provides 8 kB of on-chip RAM accessible to USB by DMA.
*  One or two (LPC2141/2 vs. LPC2144/6/8) 10-bit A/D converters provide a total of 6/14analog inputs, with conversion times as low as 2.44 us per channel.
* Single 10-bit D/A converter provides variable analog output.
* Two 32-bit timers/external event counters (with four capture and four compare channels each), PWM unit (six outputs) and watchdog.
*  Low power real-time clock with independent power and dedicated 32 kHz clock input.
* Multiple serial interfaces including two UARTs (16C550), two Fast 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, USB, Brown-Out Detect (BOD) or Real-Time Clock (RTC).
*  Single power supply chip with Power-On Reset (POR) and BOD circuits: CPU operating voltage range of 3.0 V to 3.6 V (3.3 V ± 10 %) with 5 V tolerant I/O pads.


PIN DIAGRAM OF LPC2148:










ARM: Advance RISC Machine

ARM: Advance RISC Machine

ARM was established as a joint venture between Acorn, Apple and VLSI between Acorn, Apple and VLSI in November 1990

ARM is the industry's leading provider of 16/32-bit embedded
RISC microprocessor solutions.

The company licenses its high-performance, low-cost, power-efficient RISC processors  peripherals  and system chip efficient RISC processors,peripherals, and system-chipdesigns to leading international electronics companies

ARM provides comprehensive support required in developing a complete system

ARM Holdings is a technology company headquartered in Cambridge  England  UK Cambridge, England, UK.

The company is best known for its processors, although it also designs, licenses and sells software development tools under designs,licenses and sells software development tools under the Real View and KEIL brands, systems and platforms, system-on-a-chip infrastructure and software.

ARM grant license of core to different silicon vendors lik eg ATMEL, NXP, Cirrus logic etc These companies make ICs

Examples are: LPC2148 from NXP, AT91RM9200 from ATMEL


 ARM identification:


 For Example : ARM 7 TDMI (LPC2148) 


ARM 7  modes:
  1. User mode – all normal application run under this mode
  2. FIQ mode – all fast interrupt data transfer or channel process service provided under this mode
  3. IRQ mode – vectored(priority based) interrupt handler
  4. Supervision mode – protected mode for the operating system
  5. System mode – all operating related task
  6. Abort mode – entered after a data or instruction Pre-fetch Abort exception
  7. Undefined mode – entered when an undefined instruction is executed.