Emb Lab Manual

download Emb Lab Manual

of 73

Transcript of Emb Lab Manual

  • 8/13/2019 Emb Lab Manual

    1/73

    MRK IT

    EC1404A EMBEDDED SYSTEMSLAB MANUAL

    CREATED BY

  • 8/13/2019 Emb Lab Manual

    2/73

    MRK IT

    INTERFACING USING C PROGRAM

    AIM:

    To design a) Buzzer b) Relay and Interfacing of relay with buzzer using ARM 7

    technology.

    APPARATUS REQUIRED:

    SOFTWARE: IAR system workbench

    HARDWARE: RS232 CABLE, ARM 7, Adapter (0 5V)

    OPERATING SYSTEM: Windows XP

    THEORY:

    One end of the electromagnet wire is connected directly to one end of the electricalcircuits. The other end of the wire connects to a metal contact which is adjacent to a moving arm.

    The contact arm is a thin piece of light conductive metal, with a thin iron bar soldered to

    the electrical circuit. When turned off, the free end of the ARM resets against the contact point.

    This forms a connection between that the end of the circuit.

    In this circuit, a switch is controlling power to the electromagnet. When it is switched

    ON, the electromagnet attracts the armature.

    The armature is acting as a switch in the second circuit. When the electromagnet is

    energized, the armature completes the second circuit. When the electromagnet is not energizedthe spring pulls the armature energy and the circuit is not complete.

    When your propose relay, you generally have control over several variables. The voltage

    and current that is needed to activate the armature. The maximum voltage and current that can

    run through the armature and the armature contacts the number of armature( generally one to

    two). The number of contacts for the armature whether the contact is normally open or normally

    closed.

    PROCEDURE:

    FOR CREATING NEW PROJECT:

    Open IAR embedded workbench To create a new project, choose project and select create new project.

  • 8/13/2019 Emb Lab Manual

    3/73

  • 8/13/2019 Emb Lab Manual

    4/73

    MRK IT

    Then click the Start button.

    PROGRAM FOR BUZZER FUNCTIONING:

    #include

    void LPC2148PLLInit(void);

    unsigned int i;

    void delay_ms()

    {

    int i;

    for(i=0;i

  • 8/13/2019 Emb Lab Manual

    5/73

    MRK IT

    delay_ms();

    }

    }

    void LPC2148PLLInit(void)

    {

    int loop_ctr; /* Configure PLL0, which determines the CPU clock */

    PLLCFG = 0x00000024; /* Use PLL values of M = 4 and P = 2 */

    PLLCON_bit.PLLE = 1; /* Set the PLL Enable bit */

    PLLFEED = 0xAA; /* Write to the PLL Feed register */

    PLLFEED = 0x55;

    loop_ctr = 10000; /* Wait for the PLL to lock into the new frequency */

    while (((PLLSTAT_bit.PLOCK) == 0) && (loop_ctr > 0))

    {

    loop_ctr--;

    }

    PLLCON_bit.PLLC = 1; /* Connect the PLL */

    PLLFEED = 0xAA; /* Write to the PLL Feed register */

    PLLFEED = 0x55;

    // VPBDIV = 0x00000001; /* Set the VPB frequency to one-half of the CPU clock */

    }

    PROGRAM FOR RELAY FUNCTIONING:

    #include

    static void delay(void )

    {

  • 8/13/2019 Emb Lab Manual

    6/73

    MRK IT

    volatile int i,j;

    for (i=0;i

  • 8/13/2019 Emb Lab Manual

    7/73

    MRK IT

    {

    PINSEL1 = 0x00000000;

    IO0DIR = 0x0fF00000; //0000 0000 0000 0000

    while(1)

    {

    IO0SET = 0X02F00000;

    delay();

    IO0CLR = 0X02F00000;

    delay();

    }

    }

    RESULT:

    Thus the interfacing of Buzzer with Relay is designed using ARM 7 technology and its output

    was verified.

  • 8/13/2019 Emb Lab Manual

    8/73

    MRK IT

    LED INTERFACE

    AIM:

    To display the status of LED with delay using ARM 7 technology.

    APPARATUS REQUIRED:

    SOFTWARE: IAR system workbench

    HARDWARE: RS232 CABLE, ARM 7, Adapter (0 5V)

    OPERATING SYSTEM: Windows XP

    THEORY:

    This experiment is to glow the light emitting diode (LED). LED is a special diode that

    emits light upon application of a potential difference greater than its forward bias voltage acrossits terminals. A LED can be forward biased or reverse biased.

    The ARM LPC controller pins numbered H16, H8, H48, H44, H40 and H36 are used to

    drive the buffer 744C244.

    PROCEDURE:

    FOR CREATING NEW PROJECT:

    Open IAR embedded workbench To create a new project, choose project and select create new project. Give a file name for the project. Choose FILE menu and select NEW file. Edit the application code in C language. To save the C file choose file and then select Save As and save the file with the extension

    of .c [filename.c].

    In the workspace window, select the file name and then right click on the file, chooseAdd and Add filename.c.

    Then choose options on the same workspace window. Choose Device as NXPNXPLPC2148.

  • 8/13/2019 Emb Lab Manual

    9/73

    MRK IT

    Choose Linker in the category and select the override default. In that menu, choose

    Select othersoutput format as Intel extended.

    Choose config menu to select override default. In that box, choose the path IARsystems embedded workbench 4.0 kickstart ARM examples NXP

    LPC214XIAR-LPC-214XADCconfigurationflash.xcl.

    Right click on the workspace for rebuilding the program.FOR DOWNLOADING THE PROGRAM:

    In step 1 chooseCOM PortCOM 1

    Baud rate 9600

    Device LPC 2148

    Interface None

    Oscillator frequency12MHz

    In step 2 select Erase blocks used by Hex file; In step 3 browse the hex file. In step 4 select Verify after programming. Then click the Start button.

    PROGRAM FOR LED FUNCTIONING:

    #include

    void LPC2148PLLInit(void);

    unsigned int i;

    void delay_ms()

    {

    int i,j;

    for(i=0;i

  • 8/13/2019 Emb Lab Manual

    10/73

    MRK IT

    for(j=0;j

  • 8/13/2019 Emb Lab Manual

    11/73

    MRK IT

    }

    delay_ms();

    }

    }

    void LPC2148PLLInit(void)

    {

    int loop_ctr; /* Configure PLL0, which determines the CPU clock */

    PLLCFG = 0x00000024; /* Use PLL values of M = 4 and P = 2 */

    PLLCON_bit.PLLE = 1; /* Set the PLL Enable bit */

    PLLFEED = 0xAA; /* Write to the PLL Feed register */

    PLLFEED = 0x55;

    loop_ctr = 10000; /* Wait for the PLL to lock into the new frequency */

    while (((PLLSTAT_bit.PLOCK) == 0) && (loop_ctr > 0))

    {

    loop_ctr--;

    }

    PLLCON_bit.PLLC = 1; /* Connect the PLL */

    PLLFEED = 0xAA; /* Write to the PLL Feed register */

    PLLFEED = 0x55;

    // VPBDIV = 0x00000001; /* Set the VPB frequency to one-half of the CPU clock */

    }

    RESULT:

    Thus the program for LED functioning is developed and implemented using ARM 7

    technology.

  • 8/13/2019 Emb Lab Manual

    12/73

    MRK IT

    SEVEN SEGMENT DISPLAY

    AIM:

    To develop a program for the seven segment display and implementing using the ARM 7

    technology.

    APPARATUS REQUIRED:

    SOFTWARE: IAR system workbench

    HARDWARE: RS232 CABLE, ARM 7, Adapter (0 5V)

    OPERATING SYSTEM: Windows XP

    THEORY:

    A seven segment display is a form of an electronic display device displaying decimalnumerical. They are commonly used in digital clocks, electronic meters etc. There are two types

    of displays available, common anode and common cathode.

    The LED is an seven segment display which is not isolated from each other.

    In common cathode, cathodes are connected together and the anodes are connected

    individually. In this, we need to give 1 as an input for all LEDs to glow. In common anode, all

    anodes are connected together while the cathodes are connected individually. In this, we need to

    give 0 as input for all LEDs to be glown.

    PROCEDURE:

    FOR CREATING NEW PROJECT:

    Open IAR embedded workbench To create a new project, choose project and select create new project. Give a file name for the project. Choose FILE menu and select NEW file. Edit the application code in C language. To save the C file choose file and then select Save As and save the file with the extension

    of .c [filename.c].

  • 8/13/2019 Emb Lab Manual

    13/73

    MRK IT

    In the workspace window, select the file name and then right click on the file, chooseAdd and Add filename.c.

    Then choose options on the same workspace window.

    Choose Device as NXP

    NXPLPC2148. Choose Linker in the category and select the override default. In that menu, choose

    Select othersoutput format as Intel extended. Choose config menu to select override default. In that box, choose the path IAR

    systems embedded workbench 4.0 kickstart ARM examples NXP

    LPC214XIAR-LPC-214XADCconfigurationflash.xcl.

    Right click on the workspace for rebuilding the program.FOR DOWNLOADING THE PROGRAM:

    In step 1 chooseCOM PortCOM 1

    Baud rate 9600

    Device LPC 2148

    Interface

    None

    Oscillator frequency12MHz

    In step 2 select Erase blocks used by Hex file; In step 3 browse the hex file. In step 4 select Verify after programming. Then click the Start button.

    PROGRAM FOR SEVEN SEGMENT DISPLAY:

    #include

    #include

    #define DESIRED_BAUDRATE 19200

  • 8/13/2019 Emb Lab Manual

    14/73

    MRK IT

    #define CRYSTAL_FREQUENCY_IN_HZ 12000000

    #define PCLK CRYSTAL_FREQUENCY_IN_HZ // since VPBDIV=0x01

    #define DIVISOR (PCLK/(16*DESIRED_BAUDRATE))

    int i,temp,Temp1,addr;

    int i2c0,i2c1,i2c2,l;

    unsigned char i2c_data[] = {0x00,0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7c,0x07,0x7f,0x67};

    static void delay(void )

    {

    volatile int i,j;

    for (i=0;i

  • 8/13/2019 Emb Lab Manual

    15/73

    MRK IT

    temp=I2C0STAT;

    //SLAVE ADDRESS

    2C0DAT=add;

    I2C0CONCLR=0x28;

    temp=I2C0STAT;

    delay();

    while(temp!=0x18)

    {

    temp=I2C0STAT;

    delay();

    }

    //HIGHER ORDER ADDRESS

    I2C0DAT=a;

    I2C0CONCLR=0x08;

    temp=I2C0STAT;

    while(temp!=0x28)

    {

    temp=I2C0STAT;//& 0x28;

    delay();

    }

    //STOP CONDITION

    I2C0CONSET=0x10;

    I2C0CONCLR=0x8;

    delay1();

    }

    int putchar(int ch)

  • 8/13/2019 Emb Lab Manual

    16/73

    MRK IT

    {

    while (!(U0LSR&0x20)) {}

    return(U0THR=ch);

    }

    void UARTInit()

    {

    PINSEL0=0x00000055;

    U0LCR=0x83;

    VPBDIV=0x01;

    U0DLL=DIVISOR&0xFF;

    U0DLM=DIVISOR>>8;

    U0LCR=0x03 ;

    U0FCR=0x05 ;

    }

    void main()

    {

    UARTInit();

    I2C0CONCLR=0x6C; //clear I2C0CONCLR register

    I2C0CONSET=0x40; //Enable I2C.

    I2C0SCLH=110;

    I2C0SCLL=90;

    while(1)

    {

    for(int i=0;i

  • 8/13/2019 Emb Lab Manual

    17/73

    MRK IT

    i2c_write(i2c_data[i],0x42);

    for(int i=0;i

  • 8/13/2019 Emb Lab Manual

    18/73

    MRK IT

    DIP SWITCH AND LEDs

    AIM:

    To display the status of DIP switch on LEDs.

    APPARATUS REQUIRED:

    SOFTWARE: IAR system workbench

    HARDWARE: RS232 CABLE, ARM 7, Adapter (0 5V)

    OPERATING SYSTEM: Windows XP

    THEORY:

    A DIP switch is a set of manual electronics switch that are packed in a group of standard

    dual-in-line pin (DIP). This type of switch is designed to be used on a printed circuit board alongwith other electronic components and is commonly used to customize the behavior of an DIP

    switch as an alternative to jumper blocks. Their main advantages are they are quicker to change

    and these are no parts to lose.

    PROCEDURE:

    FOR CREATING NEW PROJECT:

    Open IAR embedded workbench

    To create a new project, choose project and select create new project.

    Give a file name for the project. Choose FILE menu and select NEW file. Edit the application code in C language. To save the C file choose file and then select Save As and save the file with the extension

    of .c [filename.c].

    In the workspace window, select the file name and then right click on the file, chooseAdd and Add filename.c.

    Then choose options on the same workspace window. Choose Device as NXPNXPLPC2148.

  • 8/13/2019 Emb Lab Manual

    19/73

    MRK IT

    Choose Linker in the category and select the override default. In that menu, choose

    Select othersoutput format as Intel extended.

    Choose config menu to select override default. In that box, choose the path IARsystems embedded workbench 4.0 kickstart ARM examples NXP

    LPC214XIAR-LPC-214XADCconfigurationflash.xcl.

    Right click on the workspace for rebuilding the program.FOR DOWNLOADING THE PROGRAM:

    In step 1 chooseCOM PortCOM 1

    Baud rate 9600

    Device LPC 2148

    Interface None

    Oscillator frequency12MHz

    In step 2 select Erase blocks used by Hex file; In step 3 browse the hex file. In step 4 select Verify after programming. Then click the Start button.

    PROGRAM FOR SWITCH FUNCTIONING:

    #include

    #include

    #define BAUD 19200

    void ARM_INIT()

    {

    // P1.16 to P1.23 used for LED.and P1.24 to P1.31 used for DIP Switch.

    //GPIO Initialisation

  • 8/13/2019 Emb Lab Manual

    20/73

    MRK IT

    PINSEL0 = 0x00000000; //Pin selection for GPIO

    PINSEL1 = 0x00000000; //Pin selection for GPIO

    PINSEL2 = 0x00000000; //Pin selection for GPIO

    IO1DIR = 0X00FF0000; // P1.24 to P1.31 --> input and P1.16 to P1.23 --> output.

    IO0DIR = 0xFFFFFFFF;

    }

    static void delay(void ) //delay routine

    {

    volatile int i,j;

    for (i=0;i 0x08 ; //Read Switch status and switch

    //value send to LED PORT line

    delay();

    }

    }

  • 8/13/2019 Emb Lab Manual

    21/73

  • 8/13/2019 Emb Lab Manual

    22/73

    MRK IT

    KEYPAD OPERATION USING LINUX

    AIM:

    To write a program for keypad operation using ARM 7 technology.

    APPARATUS REQUIRED:

    SOFTWARE: GTK term.

    HARDWARE: RS232 CABLE, ARM 7, Adapter (0 5V)

    OPERATING SYSTEM: Linux.

    THEORY:

    Switches are devices that have two positions ON and OFF, which have a toggle to

    establish or break a connection. The ViARM 2378 OEM board has 5 toggle switches.

    PROCEDURE:

    Right click on the desktop window in Linux Select the open terminal and choose the communication window. Type cd / command as the path changes as [ root @ Local host /]. Type cd VCP_15_Linux and the commands changes as [ root @ Local host

    VCP_15_Linux] #

    To open program, type cd , for eg. To open keypad program type cdkeypad.

    To compile the program, use the command make all. Switch ON the kit and set the key in programming mode. To download the program to ARM 7, type the command

    .lpc21isp hex main.hex /dev/ttyS0 19200 12000

    Where ttyS0 serial port

    19200Baud rate

    12000clock frequency.

  • 8/13/2019 Emb Lab Manual

    23/73

    MRK IT

    Keep the switch in the kit at execution mode for executing the program. Open the GTK terminal for displaying the output.

    CIRCUIT DIAGRAM:

    PROGRAM FOR KEYPAD OPERATION:

    #include "LPC23xx.h"void delay(void){

    for(int i=0;i

  • 8/13/2019 Emb Lab Manual

    24/73

    MRK IT

    FIO4SET=0X0000000E;switch (FIO4PIN&0XF){case 0x6:

    send_serial_data('2');

    break;case 0xa:send_serial_data('1');break;case 0xc:send_serial_data('5');break;}FIO4CLR=0X0000000E;

    delay();FIO4SET=0X0000000D;

    switch(FIO4PIN&0xf){case 0xc:

    send_serial_data('3');break;

    }

    FIO4CLR=0X0000000D;delay();FIO2CLR=0X00000800;switch(FIO2PIN1&0xf){case 0x7:send_serial_data('4');break;}delay();

    }}

    int main (void){

    unsigned int Fdiv;FIO4DIR = 0XFF000fff;

  • 8/13/2019 Emb Lab Manual

    25/73

    MRK IT

    init_timer( ((72000000/100) - 1 ));PINSEL0 = 0x00000050;U0LCR = 0x83; // 8 bits, no Parity, 1 Stop bitFdiv = ( 72000000 / 16 ) / 19200 ; //baud rateU0DLM = Fdiv / 256;

    U0DLL = Fdiv % 256;U0LCR = 0x03; // DLAB = 0send_serial_data('Z');send_serial_data(0x0d);send_serial_data(0x0a);key_routine();return(0);

    }

    RESULT:

    Thus the program for keypad operation is performed using ASM 7 technology.

  • 8/13/2019 Emb Lab Manual

    26/73

    MRK IT

    LED OPERATION USING LINUX

    AIM:

    To write a program for LED functioning using ARM 7 technology.

    APPARATUS REQUIRED:

    SOFTWARE: GTK term.

    HARDWARE: RS232 CABLE, ARM 7, Adapter (0 5V)

    OPERATING SYSTEM: Linux.

    THEORY:

    Light Emitting Diodes are most commonly used components for displaying pins digital

    state. ViARM 2378 has 8 LEDs that are connected to the port line.

    PROCEDURE:

    Right click on the desktop window in Linux Select the open terminal and choose the communication window. Type cd / command as the path changes as [ root @ Local host /]. Type cd VCP_15_Linux and the commands changes as [ root @ Local host

    VCP_15_Linux] #

    To open program, type cd , for eg. To open LED program type cd led. To compile the program, use the command make all. Switch ON the kit and set the key in programming mode. To download the program to ARM 7, type the command

    .lpc21isp hex main.hex /dev/ttyS0 19200 12000

    Where ttyS0

    serial port19200Baud rate

    12000clock frequency.

    Keep the switch in the kit at execution mode for executing the program.

  • 8/13/2019 Emb Lab Manual

    27/73

    MRK IT

    CIRCUIT DIAGRAM:

    PROGRAM FOR LED OPERATION:

    #include "LPC23xx.h"

    /**********************************************************************************************************

    Routine to set processor and pheripheral clock******************************************************************************

    *****************************/void TargetResetInit(void){// 72 Mhz Frequencyif ((PLLSTAT & 0x02000000) > 0){

    /* If the PLL is already running */PLLCON &= ~0x02; /* Disconnect the PLL */PLLFEED = 0xAA; /* PLL register update sequence, 0xAA, 0x55

    */PLLFEED = 0x55;

    }PLLCON &= ~0x01; /* Disable the PLL */PLLFEED = 0xAA; /* PLL register update sequence, 0xAA, 0x55

    */PLLFEED = 0x55;SCS &= ~0x10; /* OSCRANGE = 0, Main OSC is between 1 and 20 Mhz

    */

  • 8/13/2019 Emb Lab Manual

    28/73

    MRK IT

    SCS |= 0x20; /* OSCEN = 1, Enable the main oscillator */while ((SCS & 0x40) == 0);CLKSRCSEL = 0x01; /* Select main OSC, 12MHz, as the PLL clock source

    */PLLCFG = (24

  • 8/13/2019 Emb Lab Manual

    29/73

    MRK IT

    }}return 0;

    }

    RESULT:

    Thus the program for LED operation is performed using ARM 7 technology.

  • 8/13/2019 Emb Lab Manual

    30/73

    MRK IT

    ADC PROGRAMMING IN ZIGBEE

    AIM:

    To write a program for performing ADC operation using Zigbee modules.

    APPARATUS REQUIRED:

    SOFTWARE: Zigbee modules (2), Debugger module (1), RS232 cable (1), ZRF connector (1).

    HARDWARE: Smart RF Flash programmer, WinXTalk.

    OPERATING SYSTEM: Windows XP.

    THEORY:

    Zigbee is one of the advanced wireless technology and CC2430 is the first Single Chip

    IEEE 802.15.4 and Zigbee System On Chip (SOC) RF transceiver with integratedmicrocontroller.

    In this exercise, we establish communication between 2RF modules. These modules work

    in the ISM band of 2.4GHz and have a SPI interface through which they are controlled and

    configured. Being a transceiver, they establish full duplex communication.

    PROCEDURE:

    Open Smart RF programmer and connect the RF modules to the debugger using RFconnector.

    The details of the chip is read and displayed in the window as soon as the connection isestablished.

    Select Retain IEEE address when reprogramming the chip. Click on the Read IEEE button to read the IEEE address of the module.

    PROGRAM FOR COORDINATOR:

    #include "OSAL.h"#include "ZGlobals.h"#include "AF.h"#include "aps_groups.h"#include "ZDApp.h"

    #include "Example.h"

  • 8/13/2019 Emb Lab Manual

    31/73

    MRK IT

    #include "OnBoard.h"

    /* HAL */#include "hal_led.h"#include "hal_key.h"#include "hal_adc.h"

    #include "hal_timer.h"#include "hal_uart.h"

    //#include "ioCC2430.h"

    uint8 s;uint8 buffer1=0;// This list should be filled with Application specific Cluster IDs.const cId_t Example_ClusterList[EXAMPLE_MAX_CLUSTERS] ={EXAMPLE_PERIODIC_CLUSTERID,

    EXAMPLE_FLASH_CLUSTERID,EXAMPLE_PERIODIC_CLUSTERID1,EXAMPLE_PERIODIC_CLUSTERID2,EXAMPLE_PERIODIC_CLUSTERID3,EXAMPLE_PERIODIC_CLUSTERID4,EXAMPLE_PERIODIC_CLUSTERID5,EXAMPLE_PERIODIC_CLUSTERID6,EXAMPLE_PERIODIC_CLUSTERID7

    };

    const SimpleDescriptionFormat_t Example_SimpleDesc ={

    EXAMPLE_ENDPOINT, // int Endpoint;EXAMPLE_PROFID, // uint16 AppProfId[2];EXAMPLE_DEVICEID, // uint16 AppDeviceId[2];EXAMPLE_DEVICE_VERSION, // int AppDevVer:4;EXAMPLE_FLAGS, // int AppFlags:4;EXAMPLE_MAX_CLUSTERS, // uint8 AppNumInClusters;(cId_t *)Example_ClusterList, // uint8 *pAppInClusterList;EXAMPLE_MAX_CLUSTERS, // uint8 AppNumInClusters;(cId_t *)Example_ClusterList // uint8 *pAppInClusterList;

    };

    // This is the Endpoint/Interface description. It is defined here, but

    // filled-in in Example_Init(). Another way to go would be to fill// in the structure here and make it a "const" (in code space). The// way it's defined in this sample app it is define in RAM.endPointDesc_t Example_epDesc;uint8 *data;

    byte *wdata;uint8 Example_TaskID; // Task ID for internal task/event processing

  • 8/13/2019 Emb Lab Manual

    32/73

    MRK IT

    // This variable will be received when// Example_Init() is called.

    devStates_t Example_NwkState;

    uint8 Example_TransID; // This is the unique message ID (counter)

    afAddrType_t Example_Periodic_DstAddr;afAddrType_t Example_Flash_DstAddr;afAddrType_t Example_Periodic_DstAddr1;

    aps_Group_t Example_Group;

    uint8 ExamplePeriodicCounter = 0;uint8 ExampleFlashCounter = 0;

    //halUARTCfg_t uartConfig;uint16 desaddr;

    uint8 s1,s2,s3,s4;uint8 flag1=0;static uint8 Example_Seqnb,Example_Seqnb1;uint8 count,count1;uint16 length;uint8 wdata_length;

    void Example_HandleKeys( uint8 shift, uint8 keys );void Example_MessageMSGCB( afIncomingMSGPacket_t *pckt );void Example_SendPeriodicMessage( void );void Example_SendFlashMessage( uint16 flashTime );

    * @fn Example_Init** @brief Initialization function for the Generic App Task.* This is called during initialization and should contain* any application specific initialization (ie. hardware* initialization/setup, table initialization, power up* notificaiton ... ).** @param task_id - the ID assigned by OSAL. This ID should be* used to send messages and set timers.

    ** @return nonevoid Example_Init( uint8 task_id ){Example_TaskID = task_id;Example_NwkState = DEV_INIT;Example_TransID = 0;

  • 8/13/2019 Emb Lab Manual

    33/73

    MRK IT

    Example_Seqnb = Example_Seqnb1 = 0x00;

    // Device hardware initialization can be added here or in main() (Zmain.c).// If the hardware is application specific - add it here.// If the hardware is other parts of the device add it in main().

    #if defined ( SOFT_START )// The "Demo" target is setup to have SOFT_START and HOLD_AUTO_START// SOFT_START is a compile option that allows the device to start// as a coordinator if one isn't found.// We are looking at a jumper (defined in ExampleHw.c) to be jumpered// together - if they are - we will start up a coordinator. Otherwise,// the device will start as a router.if ( readCoordinatorJumper() )zgDeviceLogicalType = ZG_DEVICETYPE_COORDINATOR;

    elsezgDeviceLogicalType = ZG_DEVICETYPE_ROUTER;

    #endif // SOFT_START

    #if defined ( HOLD_AUTO_START )// HOLD_AUTO_START is a compile option that will surpress ZDApp// from starting the device and wait for the application to// start the device.ZDOInitDevice(0);

    #endif

    // Setup for the periodic message's destination address// Broadcast to everyoneExample_Periodic_DstAddr.addrMode = (afAddrMode_t)AddrBroadcast;Example_Periodic_DstAddr.endPoint = EXAMPLE_ENDPOINT;

    Example_Periodic_DstAddr.addr.shortAddr = 0xFFFF;

    // Setup for the flash command's destination address - Group 1Example_Flash_DstAddr.addrMode = (afAddrMode_t)afAddrGroup;Example_Flash_DstAddr.endPoint = EXAMPLE_ENDPOINT;Example_Flash_DstAddr.addr.shortAddr = EXAMPLE_FLASH_GROUP;

    // Fill out the endpoint description.Example_epDesc.endPoint = EXAMPLE_ENDPOINT;Example_epDesc.task_id = &Example_TaskID;Example_epDesc.simpleDesc

    = (SimpleDescriptionFormat_t *)&Example_SimpleDesc;

    Example_epDesc.latencyReq = noLatencyReqs;

    // Register the endpoint description with the AFafRegister( &Example_epDesc );

    // Register for all key events - This app will handle all key eventsRegisterForKeys( Example_TaskID );

  • 8/13/2019 Emb Lab Manual

    34/73

    MRK IT

    // By default, all devices start out in Group 1Example_Group.ID = 0x0001;osal_memcpy( Example_Group.name, "Group 1", 7 );aps_AddGroup( EXAMPLE_ENDPOINT, &Example_Group );

    HalAdcInit();P1SEL|=0X00;P1DIR|=0XFF;

    HalLedSet(HAL_LED_2,HAL_LED_MODE_ON);P1_1=0;P1_2=1;P1_3=1;P1_4=0;P1_5=1;

    HalLedSet (HAL_LED_1, HAL_LED_MODE_ON);uartConfig.configured = TRUE; // 2430 don't care.

    uartConfig.baudRate = HAL_UART_BR_38400;uartConfig.flowControl = FALSE; /////TRUE;uartConfig.flowControlThreshold = 48;uartConfig.rx.maxBufSize = 64;uartConfig.tx.maxBufSize = 64;uartConfig.idleTimeout = 6; // 2430 don't care.uartConfig.intEnable = TRUE;

    // uartConfig.callBackFunc = rxCB;HalUARTOpen ( HAL_UART_PORT_1, &uartConfig);count = count1 = 0;

    }

    uint16 Example_ProcessEvent( uint8 task_id, uint16 events ){afIncomingMSGPacket_t *MSGpkt;

    if ( events & SYS_EVENT_MSG ){MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( Example_TaskID );while ( MSGpkt ){switch ( MSGpkt->hdr.event ){

    // Received when a key is pressedcase KEY_CHANGE:// Example_HandleKeys( ((keyChange_t *)MSGpkt)->state, ((keyChange_t *)MSGpkt)->keys );break;

    // Received when a messages is received (OTA) for this endpointcase AF_INCOMING_MSG_CMD:

  • 8/13/2019 Emb Lab Manual

    35/73

    MRK IT

    Example_MessageMSGCB( MSGpkt );break;

    // Received whenever the device changes state in the networkcase ZDO_STATE_CHANGE:Example_NwkState = (devStates_t)(MSGpkt->hdr.status);

    if ( (Example_NwkState == DEV_ZB_COORD)|| (Example_NwkState == DEV_ROUTER)|| (Example_NwkState == DEV_END_DEVICE) )

    {// Start sending the periodic message in a regular interval.osal_start_timerEx( Example_TaskID,

    EXAMPLE_SEND_PERIODIC_MSG_EVT,EXAMPLE_SEND_PERIODIC_MSG_TIMEOUT );

    }else{// Device is no longer in the network

    }break;

    default:break;}

    // Release the memoryosal_msg_deallocate( (uint8 *)MSGpkt );

    // Next - if one is availableMSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( Example_TaskID );

    }

    // return unprocessed eventsreturn (events ^ SYS_EVENT_MSG);

    }

    // Send a message out - This event is generated by a timer// (setup in Example_Init()).if ( events & EXAMPLE_SEND_PERIODIC_MSG_EVT ){// Send the periodic messageExample_SendPeriodicMessage();

    // Setup to send message again in normal period (+ a little jitter)osal_start_timerEx( Example_TaskID, EXAMPLE_SEND_PERIODIC_MSG_EVT,

    (EXAMPLE_SEND_PERIODIC_MSG_TIMEOUT + (osal_rand() & 0x00FF)) );

    // return unprocessed eventsreturn (events ^ EXAMPLE_SEND_PERIODIC_MSG_EVT);

  • 8/13/2019 Emb Lab Manual

    36/73

    MRK IT

    }// Discard unknown eventsreturn 0;

    }

    void Example_HandleKeys( uint8 shift, uint8 keys )

    {if ( keys & HAL_KEY_SW_2 ){/* This key sends the Flash Command is sent to Group 1.* This device will not receive the Flash Command from this* device (even if it belongs to group 1).*/

    // Example_SendFlashMessage( EXAMPLE_FLASH_DURATION );}

    if ( keys & HAL_KEY_SW_1 ){

    /* The Flashr Command is sent to Group 1.* This key toggles this device in and out of group 1.* If this device doesn't belong to group 1, this application* will not receive the Flash command sent to group 1.*/

    aps_Group_t *grp;grp = aps_FindGroup( EXAMPLE_ENDPOINT, EXAMPLE_FLASH_GROUP );if ( grp ){// Remove from the group//aps_RemoveGroup( EXAMPLE_ENDPOINT, EXAMPLE_FLASH_GROUP );

    }

    else{// Add to the flash group//aps_AddGroup( EXAMPLE_ENDPOINT, &Example_Group );

    }}

    }void Example_MessageMSGCB( afIncomingMSGPacket_t *pkt ){uint8 buf[11];uint8 d1,d2,d3,d4,d5;uint8 buf2[3];

    buf2[0]=0x0d;buf2[1]=0x0a;

    switch ( pkt->clusterId ){uint8 seqnb;

  • 8/13/2019 Emb Lab Manual

    37/73

    MRK IT

    /******* FORCE SENSOR **********/case EXAMPLE_PERIODIC_CLUSTERID1:HalLedSet (HAL_LED_1, HAL_LED_MODE_OFF);seqnb = pkt->cmd.TransSeqNumber;d1=pkt->cmd.Data[0];

    d2=d1/100;d3=d1%100;d4=d3/10;d5=d3%10;

    buf[0]=d2+0x30;buf[1]=d4+0x30;buf[2]=d5+0x30;

    HalUARTWrite( HAL_UART_PORT_1, buf2, 2 );

    HalUARTWrite( HAL_UART_PORT_1, buf, 3 );HalUARTWrite( HAL_UART_PORT_1, buf2, 2 );

    break;

    case EXAMPLE_FLASH_CLUSTERID :break;

    }}

    void Example_SendFlashMessage( uint16 flashTime ){

    }

    PROGRAM FOR END DEVICE:

    #include "OSAL.h"#include "ZGlobals.h"#include "AF.h"#include "aps_groups.h"#include "ZDApp.h"

    #include "Example.h"

    #include "OnBoard.h"

    /* HAL */#include "hal_led.h"

  • 8/13/2019 Emb Lab Manual

    38/73

    MRK IT

    #include "hal_key.h"#include "hal_adc.h"#include "hal_timer.h"#include "hal_uart.h"

    //#include "ioCC2430.h"uint8 s;uint8 buffer1=0;// This list should be filled with Application specific Cluster IDs.const cId_t Example_ClusterList[EXAMPLE_MAX_CLUSTERS] ={EXAMPLE_PERIODIC_CLUSTERID,EXAMPLE_FLASH_CLUSTERID,EXAMPLE_PERIODIC_CLUSTERID1,EXAMPLE_PERIODIC_CLUSTERID2,

    EXAMPLE_PERIODIC_CLUSTERID3,EXAMPLE_PERIODIC_CLUSTERID4,EXAMPLE_PERIODIC_CLUSTERID5,EXAMPLE_PERIODIC_CLUSTERID6,EXAMPLE_PERIODIC_CLUSTERID7

    };

    const SimpleDescriptionFormat_t Example_SimpleDesc ={EXAMPLE_ENDPOINT, // int Endpoint;EXAMPLE_PROFID, // uint16 AppProfId[2];EXAMPLE_DEVICEID, // uint16 AppDeviceId[2];EXAMPLE_DEVICE_VERSION, // int AppDevVer:4;EXAMPLE_FLAGS, // int AppFlags:4;EXAMPLE_MAX_CLUSTERS, // uint8 AppNumInClusters;(cId_t *)Example_ClusterList, // uint8 *pAppInClusterList;EXAMPLE_MAX_CLUSTERS, // uint8 AppNumInClusters;(cId_t *)Example_ClusterList // uint8 *pAppInClusterList;

    };

    // This is the Endpoint/Interface description. It is defined here, but// filled-in in Example_Init(). Another way to go would be to fill// in the structure here and make it a "const" (in code space). The// way it's defined in this sample app it is define in RAM.endPointDesc_t Example_epDesc;uint8 *data;byte *wdata;uint8 Example_TaskID; // Task ID for internal task/event processing

    // This variable will be received when

  • 8/13/2019 Emb Lab Manual

    39/73

    MRK IT

    // Example_Init() is called.devStates_t Example_NwkState;

    uint8 Example_TransID; // This is the unique message ID (counter)

    afAddrType_t Example_Periodic_DstAddr;afAddrType_t Example_Flash_DstAddr;afAddrType_t Example_Periodic_DstAddr1;

    aps_Group_t Example_Group;

    uint8 ExamplePeriodicCounter = 0;uint8 ExampleFlashCounter = 0;

    //halUARTCfg_t uartConfig;

    uint16 desaddr;uint8 s1,s2,s3,s4;uint8 flag1=0;static uint8 Example_Seqnb,Example_Seqnb1;uint8 count,count1;uint16 length;uint8 wdata_length;

    void Example_HandleKeys( uint8 shift, uint8 keys );void Example_MessageMSGCB( afIncomingMSGPacket_t *pckt );void Example_SendPeriodicMessage( void );void Example_SendFlashMessage( uint16 flashTime );

    void Example_Init( uint8 task_id ){Example_TaskID = task_id;Example_NwkState = DEV_INIT;Example_TransID = 0;Example_Seqnb = Example_Seqnb1 = 0x00;

    // Device hardware initialization can be added here or in main() (Zmain.c).// If the hardware is application specific - add it here.// If the hardware is other parts of the device add it in main().

    #if defined ( SOFT_START )// The "Demo" target is setup to have SOFT_START and HOLD_AUTO_START// SOFT_START is a compile option that allows the device to start// as a coordinator if one isn't found.

  • 8/13/2019 Emb Lab Manual

    40/73

    MRK IT

    // We are looking at a jumper (defined in ExampleHw.c) to be jumpered// together - if they are - we will start up a coordinator. Otherwise,// the device will start as a router.if ( readCoordinatorJumper() )

    zgDeviceLogicalType = ZG_DEVICETYPE_COORDINATOR;

    elsezgDeviceLogicalType = ZG_DEVICETYPE_ROUTER;#endif // SOFT_START

    #if defined ( HOLD_AUTO_START )// HOLD_AUTO_START is a compile option that will surpress ZDApp// from starting the device and wait for the application to// start the device.ZDOInitDevice(0);

    #endif

    // Setup for the periodic message's destination address// Broadcast to everyoneExample_Periodic_DstAddr.addrMode = (afAddrMode_t)AddrBroadcast;Example_Periodic_DstAddr.endPoint = EXAMPLE_ENDPOINT;Example_Periodic_DstAddr.addr.shortAddr = 0xFFFF;

    // Setup for the flash command's destination address - Group 1Example_Flash_DstAddr.addrMode = (afAddrMode_t)afAddrGroup;Example_Flash_DstAddr.endPoint = EXAMPLE_ENDPOINT;Example_Flash_DstAddr.addr.shortAddr = EXAMPLE_FLASH_GROUP;

    // Fill out the endpoint description.Example_epDesc.endPoint = EXAMPLE_ENDPOINT;Example_epDesc.task_id = &Example_TaskID;Example_epDesc.simpleDesc

    = (SimpleDescriptionFormat_t *)&Example_SimpleDesc;Example_epDesc.latencyReq = noLatencyReqs;

    // Register the endpoint description with the AFafRegister( &Example_epDesc );

    // Register for all key events - This app will handle all key eventsRegisterForKeys( Example_TaskID );

    // By default, all devices start out in Group 1Example_Group.ID = 0x0001;osal_memcpy( Example_Group.name, "Group 1", 7 );aps_AddGroup( EXAMPLE_ENDPOINT, &Example_Group );

  • 8/13/2019 Emb Lab Manual

    41/73

    MRK IT

    HalAdcInit();P1SEL|=0X00;P1DIR|=0XFF;

    HalLedSet(HAL_LED_2,HAL_LED_MODE_ON);

    P1_1=0;P1_2=1;P1_3=1;P1_4=0;P1_5=1;

    HalLedSet (HAL_LED_1, HAL_LED_MODE_ON);uartConfig.configured = TRUE; // 2430 don't care.uartConfig.baudRate = HAL_UART_BR_38400;uartConfig.flowControl = FALSE; /////TRUE;uartConfig.flowControlThreshold = 48;uartConfig.rx.maxBufSize = 64;

    uartConfig.tx.maxBufSize = 64;uartConfig.idleTimeout = 6; // 2430 don't care.uartConfig.intEnable = TRUE;// uartConfig.callBackFunc = rxCB;HalUARTOpen ( HAL_UART_PORT_1, &uartConfig);count = count1 = 0;

    * @return none*/uint16 Example_ProcessEvent( uint8 task_id, uint16 events ){afIncomingMSGPacket_t *MSGpkt;

    if ( events & SYS_EVENT_MSG ){

    MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( Example_TaskID );while ( MSGpkt ){switch ( MSGpkt->hdr.event ){// Received when a key is pressed

    case KEY_CHANGE:// Example_HandleKeys( ((keyChange_t *)MSGpkt)->state, ((keyChange_t *)MSGpkt)-

    >keys );break;

    // Received when a messages is received (OTA) for this endpointcase AF_INCOMING_MSG_CMD:Example_MessageMSGCB( MSGpkt );

  • 8/13/2019 Emb Lab Manual

    42/73

    MRK IT

    break;

    // Received whenever the device changes state in the networkcase ZDO_STATE_CHANGE:Example_NwkState = (devStates_t)(MSGpkt->hdr.status);

    if ( (Example_NwkState == DEV_ZB_COORD)|| (Example_NwkState == DEV_ROUTER)|| (Example_NwkState == DEV_END_DEVICE) )

    {// Start sending the periodic message in a regular interval.osal_start_timerEx( Example_TaskID,

    EXAMPLE_SEND_PERIODIC_MSG_EVT,EXAMPLE_SEND_PERIODIC_MSG_TIMEOUT );

    }else{

    // Device is no longer in the network}break;

    default:break;}

    // Release the memoryosal_msg_deallocate( (uint8 *)MSGpkt );

    // Next - if one is availableMSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( Example_TaskID );

    }

    // return unprocessed eventsreturn (events ^ SYS_EVENT_MSG);

    }

    // Send a message out - This event is generated by a timer// (setup in Example_Init()).if ( events & EXAMPLE_SEND_PERIODIC_MSG_EVT ){

    // Send the periodic messageExample_SendPeriodicMessage();

    // Setup to send message again in normal period (+ a little jitter)osal_start_timerEx( Example_TaskID, EXAMPLE_SEND_PERIODIC_MSG_EVT,

    (EXAMPLE_SEND_PERIODIC_MSG_TIMEOUT + (osal_rand() & 0x00FF)) );

  • 8/13/2019 Emb Lab Manual

    43/73

    MRK IT

    // return unprocessed eventsreturn (events EXAMPLE_SEND_PERIODIC_MSG_EVT);

    }

    // Discard unknown eventsreturn 0;}

    void Example_HandleKeys( uint8 shift, uint8 keys ){if ( keys & HAL_KEY_SW_2 ){

    /* This key sends the Flash Command is sent to Group 1.* This device will not receive the Flash Command from this* device (even if it belongs to group 1).

    */// Example_SendFlashMessage( EXAMPLE_FLASH_DURATION );}

    if ( keys & HAL_KEY_SW_1 ){

    aps_Group_t *grp;grp = aps_FindGroup( EXAMPLE_ENDPOINT, EXAMPLE_FLASH_GROUP );if ( grp ){// Remove from the group//aps_RemoveGroup( EXAMPLE_ENDPOINT, EXAMPLE_FLASH_GROUP );

    }else{// Add to the flash group//aps_AddGroup( EXAMPLE_ENDPOINT, &Example_Group );

    }}

    }

    void Example_MessageMSGCB( afIncomingMSGPacket_t *pkt ){uint8 buf[11];uint8 d1,d2,d3,d4,d5;uint8 buf2[3];buf2[0]=0x0d;buf2[1]=0x0a;

  • 8/13/2019 Emb Lab Manual

    44/73

    MRK IT

    switch ( pkt->clusterId ){

    uint8 seqnb;

    case EXAMPLE_PERIODIC_CLUSTERID1:HalLedSet (HAL_LED_1, HAL_LED_MODE_OFF);seqnb = pkt->cmd.TransSeqNumber;d1=pkt->cmd.Data[0];

    d2=d1/100;d3=d1%100;d4=d3/10;d5=d3%10;

    buf[0]=d2+0x30;buf[1]=d4+0x30;buf[2]=d5+0x30;

    HalUARTWrite( HAL_UART_PORT_1, buf2, 2 );HalUARTWrite( HAL_UART_PORT_1, buf, 3 );HalUARTWrite( HAL_UART_PORT_1, buf2, 2 );break;

    case EXAMPLE_FLASH_CLUSTERID :break;

    }}

    void Example_SendPeriodicMessage( void ){}

    void Example_SendFlashMessage( uint16 flashTime ){}

    RESULT:

    Thus the program for ADC functioning is performed on Zigbee modules.

  • 8/13/2019 Emb Lab Manual

    45/73

    MRK IT

    LIGHT SENSOR USING ZIGBEE

    AIM:

    To write a program for sensing light intensity using LDR in Zigbee.

    APPARATUS REQUIRED:

    SOFTWARE: Zigbee modules (2), Debugger module (1), RS232 cable (1), ZRF connector (1).

    HARDWARE: Smart RF Flash programmer, WinXTalk.

    OPERATING SYSTEM: Windows XP.

    THEORY:

    Vi sensor modules are most compatible, reliable and very easy to use for sensing and

    controlling applications. Light sensor is designed with two pin LDR ( Light Dependent Resistor).The resistor value of the LDR varies with the luminous around it.

    PROCEDURE:

    Open Smart RF programmer and connect the RF modules to the debugger using RFconnector.

    The details of the chip is read and displayed in the window as soon as the connection isestablished.

    Select Retain IEEE address when reprogramming the chip. Click on the Read IEEE button to read the IEEE address of the module.

    PROGRAM FOR COORDINATOR:

    #include "OSAL.h"#include "ZGlobals.h"#include "AF.h"#include "aps_groups.h"#include "ZDApp.h"

    #include "Example.h"

    #include "OnBoard.h"

    /* HAL */#include "hal_led.h"

  • 8/13/2019 Emb Lab Manual

    46/73

    MRK IT

    #include "hal_key.h"#include "hal_adc.h"#include "hal_timer.h"#include "hal_uart.h"

    //

    #include "ioCC2430.h"

    uint8 s;uint8 buffer1=0;// This list should be filled with Application specific Cluster IDs.const cId_t Example_ClusterList[EXAMPLE_MAX_CLUSTERS] ={EXAMPLE_PERIODIC_CLUSTERID,EXAMPLE_FLASH_CLUSTERID,EXAMPLE_PERIODIC_CLUSTERID1,EXAMPLE_PERIODIC_CLUSTERID2,EXAMPLE_PERIODIC_CLUSTERID3,

    EXAMPLE_PERIODIC_CLUSTERID4,EXAMPLE_PERIODIC_CLUSTERID5,EXAMPLE_PERIODIC_CLUSTERID6,EXAMPLE_PERIODIC_CLUSTERID7

    };

    const SimpleDescriptionFormat_t Example_SimpleDesc ={EXAMPLE_ENDPOINT, // int Endpoint;EXAMPLE_PROFID, // uint16 AppProfId[2];EXAMPLE_DEVICEID, // uint16 AppDeviceId[2];EXAMPLE_DEVICE_VERSION, // int AppDevVer:4;

    EXAMPLE_FLAGS, // int AppFlags:4;EXAMPLE_MAX_CLUSTERS, // uint8 AppNumInClusters;(cId_t *)Example_ClusterList, // uint8 *pAppInClusterList;EXAMPLE_MAX_CLUSTERS, // uint8 AppNumInClusters;(cId_t *)Example_ClusterList // uint8 *pAppInClusterList;

    };

    // This is the Endpoint/Interface description. It is defined here, but// filled-in in Example_Init(). Another way to go would be to fill// in the structure here and make it a "const" (in code space). The// way it's defined in this sample app it is define in RAM.endPointDesc_t Example_epDesc;

    uint8 *data;byte *wdata;uint8 Example_TaskID; // Task ID for internal task/event processing

    // This variable will be received when// Example_Init() is called.

    devStates_t Example_NwkState;

  • 8/13/2019 Emb Lab Manual

    47/73

    MRK IT

    uint8 Example_TransID; // This is the unique message ID (counter)

    afAddrType_t Example_Periodic_DstAddr;afAddrType_t Example_Flash_DstAddr;afAddrType_t Example_Periodic_DstAddr1;

    aps_Group_t Example_Group;

    uint8 ExamplePeriodicCounter = 0;uint8 ExampleFlashCounter = 0;

    //halUARTCfg_t uartConfig;uint16 desaddr;uint8 s1,s2,s3,s4;uint8 flag1=0;static uint8 Example_Seqnb,Example_Seqnb1;uint8 count,count1;

    uint16 length;uint8 wdata_length;

    void Example_HandleKeys( uint8 shift, uint8 keys );void Example_MessageMSGCB( afIncomingMSGPacket_t *pckt );void Example_SendPeriodicMessage( void );void Example_SendFlashMessage( uint16 flashTime );

    * @fn Example_Init*

    * @brief Initialization function for the Generic App Task.* This is called during initialization and should contain* any application specific initialization (ie. hardware* initialization/setup, table initialization, power up* notificaiton ... ).** @param task_id - the ID assigned by OSAL. This ID should be* used to send messages and set timers.** @return none

    void Example_Init( uint8 task_id ){

    Example_TaskID = task_id;Example_NwkState = DEV_INIT;Example_TransID = 0;Example_Seqnb = Example_Seqnb1 = 0x00;

    // Device hardware initialization can be added here or in main() (Zmain.c).// If the hardware is application specific - add it here.

  • 8/13/2019 Emb Lab Manual

    48/73

    MRK IT

    // If the hardware is other parts of the device add it in main().

    #if defined ( SOFT_START )// The "Demo" target is setup to have SOFT_START and HOLD_AUTO_START// SOFT_START is a compile option that allows the device to start// as a coordinator if one isn't found.

    // We are looking at a jumper (defined in ExampleHw.c) to be jumpered// together - if they are - we will start up a coordinator. Otherwise,// the device will start as a router.if ( readCoordinatorJumper() )zgDeviceLogicalType = ZG_DEVICETYPE_COORDINATOR;

    elsezgDeviceLogicalType = ZG_DEVICETYPE_ROUTER;

    #endif // SOFT_START

    #if defined ( HOLD_AUTO_START )// HOLD_AUTO_START is a compile option that will surpress ZDApp// from starting the device and wait for the application to

    // start the device.ZDOInitDevice(0);

    #endif

    // Setup for the periodic message's destination address// Broadcast to everyoneExample_Periodic_DstAddr.addrMode = (afAddrMode_t)AddrBroadcast;Example_Periodic_DstAddr.endPoint = EXAMPLE_ENDPOINT;Example_Periodic_DstAddr.addr.shortAddr = 0xFFFF;

    // Setup for the flash command's destination address - Group 1Example_Flash_DstAddr.addrMode = (afAddrMode_t)afAddrGroup;

    Example_Flash_DstAddr.endPoint = EXAMPLE_ENDPOINT;Example_Flash_DstAddr.addr.shortAddr = EXAMPLE_FLASH_GROUP;

    // Fill out the endpoint description.Example_epDesc.endPoint = EXAMPLE_ENDPOINT;Example_epDesc.task_id = &Example_TaskID;Example_epDesc.simpleDesc

    = (SimpleDescriptionFormat_t *)&Example_SimpleDesc;Example_epDesc.latencyReq = noLatencyReqs;

    // Register the endpoint description with the AFafRegister( &Example_epDesc );

    // Register for all key events - This app will handle all key eventsRegisterForKeys( Example_TaskID );

    // By default, all devices start out in Group 1Example_Group.ID = 0x0001;osal_memcpy( Example_Group.name, "Group 1", 7 );

  • 8/13/2019 Emb Lab Manual

    49/73

    MRK IT

    aps_AddGroup( EXAMPLE_ENDPOINT, &Example_Group );

    HalAdcInit();P1SEL|=0X00;P1DIR|=0XFF;

    HalLedSet(HAL_LED_2,HAL_LED_MODE_ON);P1_1=0;P1_2=1;P1_3=1;P1_4=0;P1_5=1;

    HalLedSet (HAL_LED_1, HAL_LED_MODE_ON);uartConfig.configured = TRUE; // 2430 don't care.uartConfig.baudRate = HAL_UART_BR_38400;uartConfig.flowControl = FALSE; /////TRUE;uartConfig.flowControlThreshold = 48;uartConfig.rx.maxBufSize = 64;

    uartConfig.tx.maxBufSize = 64;uartConfig.idleTimeout = 6; // 2430 don't care.uartConfig.intEnable = TRUE;// uartConfig.callBackFunc = rxCB;HalUARTOpen ( HAL_UART_PORT_1, &uartConfig);count = count1 = 0;

    }

    uint16 Example_ProcessEvent( uint8 task_id, uint16 events ){afIncomingMSGPacket_t *MSGpkt;

    if ( events & SYS_EVENT_MSG ){MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( Example_TaskID );while ( MSGpkt ){switch ( MSGpkt->hdr.event ){// Received when a key is pressed

    case KEY_CHANGE:// Example_HandleKeys( ((keyChange_t *)MSGpkt)->state, ((keyChange_t *)MSGpkt)->keys );break;

    // Received when a messages is received (OTA) for this endpointcase AF_INCOMING_MSG_CMD:Example_MessageMSGCB( MSGpkt );

    break;

    // Received whenever the device changes state in the network

  • 8/13/2019 Emb Lab Manual

    50/73

    MRK IT

    case ZDO_STATE_CHANGE:Example_NwkState = (devStates_t)(MSGpkt->hdr.status);if ( (Example_NwkState == DEV_ZB_COORD)

    || (Example_NwkState == DEV_ROUTER)|| (Example_NwkState == DEV_END_DEVICE) )

    {

    // Start sending the periodic message in a regular interval.osal_start_timerEx( Example_TaskID,

    EXAMPLE_SEND_PERIODIC_MSG_EVT,EXAMPLE_SEND_PERIODIC_MSG_TIMEOUT );

    }else{// Device is no longer in the network

    }break;

    default:

    break;}

    // Release the memoryosal_msg_deallocate( (uint8 *)MSGpkt );

    // Next - if one is availableMSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( Example_TaskID );

    }

    // return unprocessed eventsreturn (events ^ SYS_EVENT_MSG);

    }

    // Send a message out - This event is generated by a timer// (setup in Example_Init()).if ( events & EXAMPLE_SEND_PERIODIC_MSG_EVT ){// Send the periodic messageExample_SendPeriodicMessage();

    // Setup to send message again in normal period (+ a little jitter)osal_start_timerEx( Example_TaskID, EXAMPLE_SEND_PERIODIC_MSG_EVT,

    (EXAMPLE_SEND_PERIODIC_MSG_TIMEOUT + (osal_rand() & 0x00FF)) );

    // return unprocessed eventsreturn (events ^ EXAMPLE_SEND_PERIODIC_MSG_EVT);

    }// Discard unknown eventsreturn 0;

    }

  • 8/13/2019 Emb Lab Manual

    51/73

    MRK IT

    void Example_HandleKeys( uint8 shift, uint8 keys ){if ( keys & HAL_KEY_SW_2 ){/* This key sends the Flash Command is sent to Group 1.

    * This device will not receive the Flash Command from this* device (even if it belongs to group 1).*/

    // Example_SendFlashMessage( EXAMPLE_FLASH_DURATION );}

    if ( keys & HAL_KEY_SW_1 ){/* The Flashr Command is sent to Group 1.* This key toggles this device in and out of group 1.* If this device doesn't belong to group 1, this application* will not receive the Flash command sent to group 1.

    */aps_Group_t *grp;grp = aps_FindGroup( EXAMPLE_ENDPOINT, EXAMPLE_FLASH_GROUP );if ( grp ){// Remove from the group//aps_RemoveGroup( EXAMPLE_ENDPOINT, EXAMPLE_FLASH_GROUP );

    }else{// Add to the flash group//aps_AddGroup( EXAMPLE_ENDPOINT, &Example_Group );

    }}

    }void Example_MessageMSGCB( afIncomingMSGPacket_t *pkt ){uint8 buf[11];uint8 d1,d2,d3,d4,d5;uint8 buf2[3];buf2[0]=0x0d;buf2[1]=0x0a;

    switch ( pkt->clusterId ){uint8 seqnb;

    /******* FORCE SENSOR **********/case EXAMPLE_PERIODIC_CLUSTERID1:HalLedSet (HAL_LED_1, HAL_LED_MODE_OFF);

  • 8/13/2019 Emb Lab Manual

    52/73

  • 8/13/2019 Emb Lab Manual

    53/73

    MRK IT

    #include "hal_uart.h"

    //#include "ioCC2430.h"uint8 s;

    uint8 buffer1=0;// This list should be filled with Application specific Cluster IDs.const cId_t Example_ClusterList[EXAMPLE_MAX_CLUSTERS] ={EXAMPLE_PERIODIC_CLUSTERID,EXAMPLE_FLASH_CLUSTERID,EXAMPLE_PERIODIC_CLUSTERID1,EXAMPLE_PERIODIC_CLUSTERID2,EXAMPLE_PERIODIC_CLUSTERID3,EXAMPLE_PERIODIC_CLUSTERID4,EXAMPLE_PERIODIC_CLUSTERID5,

    EXAMPLE_PERIODIC_CLUSTERID6,EXAMPLE_PERIODIC_CLUSTERID7};

    const SimpleDescriptionFormat_t Example_SimpleDesc ={EXAMPLE_ENDPOINT, // int Endpoint;EXAMPLE_PROFID, // uint16 AppProfId[2];EXAMPLE_DEVICEID, // uint16 AppDeviceId[2];EXAMPLE_DEVICE_VERSION, // int AppDevVer:4;EXAMPLE_FLAGS, // int AppFlags:4;EXAMPLE_MAX_CLUSTERS, // uint8 AppNumInClusters;(cId_t *)Example_ClusterList, // uint8 *pAppInClusterList;EXAMPLE_MAX_CLUSTERS, // uint8 AppNumInClusters;(cId_t *)Example_ClusterList // uint8 *pAppInClusterList;

    };

    // This is the Endpoint/Interface description. It is defined here, but// filled-in in Example_Init(). Another way to go would be to fill// in the structure here and make it a "const" (in code space). The// way it's defined in this sample app it is define in RAM.endPointDesc_t Example_epDesc;uint8 *data;byte *wdata;uint8 Example_TaskID; // Task ID for internal task/event processing

    // This variable will be received when// Example_Init() is called.

    devStates_t Example_NwkState;

  • 8/13/2019 Emb Lab Manual

    54/73

    MRK IT

    uint8 Example_TransID; // This is the unique message ID (counter)

    afAddrType_t Example_Periodic_DstAddr;afAddrType_t Example_Flash_DstAddr;afAddrType_t Example_Periodic_DstAddr1;

    aps_Group_t Example_Group;

    uint8 ExamplePeriodicCounter = 0;uint8 ExampleFlashCounter = 0;

    //halUARTCfg_t uartConfig;uint16 desaddr;uint8 s1,s2,s3,s4;uint8 flag1=0;

    static uint8 Example_Seqnb,Example_Seqnb1;uint8 count,count1;uint16 length;uint8 wdata_length;

    void Example_HandleKeys( uint8 shift, uint8 keys );void Example_MessageMSGCB( afIncomingMSGPacket_t *pckt );void Example_SendPeriodicMessage( void );void Example_SendFlashMessage( uint16 flashTime );

    void Example_Init( uint8 task_id ){Example_TaskID = task_id;Example_NwkState = DEV_INIT;Example_TransID = 0;Example_Seqnb = Example_Seqnb1 = 0x00;

    // Device hardware initialization can be added here or in main() (Zmain.c).// If the hardware is application specific - add it here.// If the hardware is other parts of the device add it in main().

    #if defined ( SOFT_START )// The "Demo" target is setup to have SOFT_START and HOLD_AUTO_START// SOFT_START is a compile option that allows the device to start// as a coordinator if one isn't found.// We are looking at a jumper (defined in ExampleHw.c) to be jumpered// together - if they are - we will start up a coordinator. Otherwise,// the device will start as a router.

  • 8/13/2019 Emb Lab Manual

    55/73

    MRK IT

    if ( readCoordinatorJumper() )zgDeviceLogicalType = ZG_DEVICETYPE_COORDINATOR;

    elsezgDeviceLogicalType = ZG_DEVICETYPE_ROUTER;

    #endif // SOFT_START

    #if defined ( HOLD_AUTO_START )// HOLD_AUTO_START is a compile option that will surpress ZDApp// from starting the device and wait for the application to// start the device.ZDOInitDevice(0);

    #endif

    // Setup for the periodic message's destination address// Broadcast to everyoneExample_Periodic_DstAddr.addrMode = (afAddrMode_t)AddrBroadcast;

    Example_Periodic_DstAddr.endPoint = EXAMPLE_ENDPOINT;Example_Periodic_DstAddr.addr.shortAddr = 0xFFFF;

    // Setup for the flash command's destination address - Group 1Example_Flash_DstAddr.addrMode = (afAddrMode_t)afAddrGroup;Example_Flash_DstAddr.endPoint = EXAMPLE_ENDPOINT;Example_Flash_DstAddr.addr.shortAddr = EXAMPLE_FLASH_GROUP;

    // Fill out the endpoint description.Example_epDesc.endPoint = EXAMPLE_ENDPOINT;Example_epDesc.task_id = &Example_TaskID;Example_epDesc.simpleDesc

    = (SimpleDescriptionFormat_t *)&Example_SimpleDesc;Example_epDesc.latencyReq = noLatencyReqs;

    // Register the endpoint description with the AFafRegister( &Example_epDesc );

    // Register for all key events - This app will handle all key eventsRegisterForKeys( Example_TaskID );

    // By default, all devices start out in Group 1Example_Group.ID = 0x0001;osal_memcpy( Example_Group.name, "Group 1", 7 );aps_AddGroup( EXAMPLE_ENDPOINT, &Example_Group );

    HalAdcInit();P1SEL|=0X00;P1DIR|=0XFF;

  • 8/13/2019 Emb Lab Manual

    56/73

    MRK IT

    HalLedSet(HAL_LED_2,HAL_LED_MODE_ON);P1_1=0;P1_2=1;P1_3=1;

    P1_4=0;P1_5=1;HalLedSet (HAL_LED_1, HAL_LED_MODE_ON);uartConfig.configured = TRUE; // 2430 don't care.uartConfig.baudRate = HAL_UART_BR_38400;uartConfig.flowControl = FALSE; /////TRUE;uartConfig.flowControlThreshold = 48;uartConfig.rx.maxBufSize = 64;uartConfig.tx.maxBufSize = 64;uartConfig.idleTimeout = 6; // 2430 don't care.uartConfig.intEnable = TRUE;

    // uartConfig.callBackFunc = rxCB;HalUARTOpen ( HAL_UART_PORT_1, &uartConfig);count = count1 = 0;

    * @return none*/uint16 Example_ProcessEvent( uint8 task_id, uint16 events ){afIncomingMSGPacket_t *MSGpkt;

    if ( events & SYS_EVENT_MSG ){

    MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( Example_TaskID );while ( MSGpkt ){switch ( MSGpkt->hdr.event ){// Received when a key is pressed

    case KEY_CHANGE:// Example_HandleKeys( ((keyChange_t *)MSGpkt)->state, ((keyChange_t *)MSGpkt)-

    >keys );break;

    // Received when a messages is received (OTA) for this endpointcase AF_INCOMING_MSG_CMD:Example_MessageMSGCB( MSGpkt );break;

    // Received whenever the device changes state in the network

  • 8/13/2019 Emb Lab Manual

    57/73

    MRK IT

    case ZDO_STATE_CHANGE:Example_NwkState = (devStates_t)(MSGpkt->hdr.status);if ( (Example_NwkState == DEV_ZB_COORD)

    || (Example_NwkState == DEV_ROUTER)|| (Example_NwkState == DEV_END_DEVICE) )

    {// Start sending the periodic message in a regular interval.osal_start_timerEx( Example_TaskID,

    EXAMPLE_SEND_PERIODIC_MSG_EVT,EXAMPLE_SEND_PERIODIC_MSG_TIMEOUT );

    }else{// Device is no longer in the network

    }break;

    default:break;}

    // Release the memoryosal_msg_deallocate( (uint8 *)MSGpkt );

    // Next - if one is availableMSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( Example_TaskID );

    }

    // return unprocessed eventsreturn (events ^ SYS_EVENT_MSG);

    }

    // Send a message out - This event is generated by a timer// (setup in Example_Init()).if ( events & EXAMPLE_SEND_PERIODIC_MSG_EVT ){

    // Send the periodic messageExample_SendPeriodicMessage();

    // Setup to send message again in normal period (+ a little jitter)osal_start_timerEx( Example_TaskID, EXAMPLE_SEND_PERIODIC_MSG_EVT,

    (EXAMPLE_SEND_PERIODIC_MSG_TIMEOUT + (osal_rand() & 0x00FF)) );

    // return unprocessed eventsreturn (events EXAMPLE_SEND_PERIODIC_MSG_EVT);

  • 8/13/2019 Emb Lab Manual

    58/73

    MRK IT

    }

    // Discard unknown eventsreturn 0;

    }

    void Example_HandleKeys( uint8 shift, uint8 keys ){if ( keys & HAL_KEY_SW_2 ){

    /* This key sends the Flash Command is sent to Group 1.* This device will not receive the Flash Command from this* device (even if it belongs to group 1).*/

    // Example_SendFlashMessage( EXAMPLE_FLASH_DURATION );}

    if ( keys & HAL_KEY_SW_1 ){

    aps_Group_t *grp;grp = aps_FindGroup( EXAMPLE_ENDPOINT, EXAMPLE_FLASH_GROUP );if ( grp ){// Remove from the group//aps_RemoveGroup( EXAMPLE_ENDPOINT, EXAMPLE_FLASH_GROUP );

    }else{// Add to the flash group//aps_AddGroup( EXAMPLE_ENDPOINT, &Example_Group );

    }}

    }

    void Example_MessageMSGCB( afIncomingMSGPacket_t *pkt ){uint8 buf[11];uint8 d1,d2,d3,d4,d5;uint8 buf2[3];buf2[0]=0x0d;buf2[1]=0x0a;

    switch ( pkt->clusterId )

  • 8/13/2019 Emb Lab Manual

    59/73

    MRK IT

    {uint8 seqnb;

    case EXAMPLE_PERIODIC_CLUSTERID1:HalLedSet (HAL_LED_1, HAL_LED_MODE_OFF);

    seqnb = pkt->cmd.TransSeqNumber;d1=pkt->cmd.Data[0];

    d2=d1/100;d3=d1%100;d4=d3/10;d5=d3%10;

    buf[0]=d2+0x30;buf[1]=d4+0x30;

    buf[2]=d5+0x30;

    HalUARTWrite( HAL_UART_PORT_1, buf2, 2 );HalUARTWrite( HAL_UART_PORT_1, buf, 3 );HalUARTWrite( HAL_UART_PORT_1, buf2, 2 );break;

    case EXAMPLE_FLASH_CLUSTERID :break;

    }}

    void Example_SendPeriodicMessage( void ){}

    void Example_SendFlashMessage( uint16 flashTime ){}

    RESULT:

    Thus the intensity of light is sensed using LDR in Zigbee.

  • 8/13/2019 Emb Lab Manual

    60/73

    MRK IT

    DESIGN AND TESTING OF TRAFFIC LIGHT CONTROLLER ON FPGA

    BOARG USING VERILOG CODE

    AIM:

    To design a traffic light controller on FPGA board using verilog codes.

    APPARATUS REQUIRED:

    * Xilinx ISE 9.1

    * FPGA kit

    * FRC cable

    *AC adapter, LPT cable.

    THEORY:

    In this program, a traffic light control is designed using verilog codes in FPGA board.

    Various states are used to control traffic. In first state, the red signal of vehicle path is maintained

    high to allow the pedestrians for the usage of road. In next state, the entire pedestrian path is

    maintained high. The green signal of one path is maintained high for certain time and after some

    time the yellow light is at high state alerting the users that the red signal will be initiated at their

    path. Red signal is at high state at that path and at the same time green signal of another path is at

    high state and the entire states will be repeated.

    PROCEDURE:

    Click on the Xilinx 9.1 and open new project. Create new source and write the necessary codes. Check syntax and click new source in process window and open implement constraints

    file.

    Open .ucf file and assign pin packages Perform implement design and from the generate program file select configure device. Switch on the kit and open IMPACT and download the bit file and verify the output.

    PROGRAM:

    Behavioral Modeling:

    module traffic(clk, reset, p1, p2, p3, p4, pt);

    input clk;

  • 8/13/2019 Emb Lab Manual

    61/73

    MRK IT

    input reset;

    output [4:0] p1; // d5,d4,d3,d2,d1

    output [4:0] p2; // d10,d9,d8,d7,d6

    output [4:0] p3; // d15,d14,d13,d12,d11

    output [4:0] p4; // d20,d19,d18,d17,d16

    output [3:0] pt; // dl1,dl2,dl3,dl4,dl5,dl6,dl7,dl8 (Pedestrain)

    reg [4:0] p1;

    reg [4:0] p2;

    reg [4:0] p3;

    reg [4:0] p4;

    reg [3:0] pt;

    reg [31:0] sig;

    always @ (posedge clk or negedge reset)

    begin

    if (reset == 1'b0) begin

    p1

  • 8/13/2019 Emb Lab Manual

    62/73

    MRK IT

    p1

  • 8/13/2019 Emb Lab Manual

    63/73

    MRK IT

    end

    6'b010000 : begin

    p1

  • 8/13/2019 Emb Lab Manual

    64/73

    MRK IT

    p4

  • 8/13/2019 Emb Lab Manual

    65/73

    MRK IT

    UCF( User Constraint File):

    I/O Pin I/O Direction Location

    Clk Input a8Reset Input J6

    Pt[0] Output l15Pt[1] Output n15Pt[2] Output p15Pt[3] Output r15P1[0] Output b14P1[1] Output c16P1[2] Output d15P1[3] Output f14P1[4] Output g14P2[0] Output g16P2[1] Output h15P2[2] Output k15P2[3] Output f15P2[4] Output g15P3[0] Output h14P3[1] Output j16P3[2] Output k16P3[3] Output m16P3[4] Output n16P4[0] Output p16P4[1] Output r16P4[2] Output c15P4[3] Output d14P4[4] Output e16

  • 8/13/2019 Emb Lab Manual

    66/73

    MRK IT

    LOGIC DIAGRAM:

    RESULT:

    Thus the traffic light controller on FPGA board is designed using verilog code and theoutput is verified.

  • 8/13/2019 Emb Lab Manual

    67/73

    MRK IT

    PERFORMANCE CHARACTERISTICS OF ARM7 AND FPGA

    AIM:

    To analyze the performance of FPGA with ARM7 using serial communication.

    APPARATUS REQUIRED:

    HARDWARE: RS232 cable, Parallel port, FPGA, ARM7 kit.

    SOFTWARE:IAR Embedded systems, , Xilinx IDE 9.1

    OPERATING SYSTEM:Windows XP.

    PROCEDURE FOR ARM 7:

    FOR CREATING NEW PROJECT:

    Open IAR embedded workbench To create a new project, choose project and select create new project. Give a file name for the project. Choose FILE menu and select NEW file. Edit the application code in C language. To save the C file choose file and then select Save As and save the file with the extension

    of .c [filename.c].

    In the workspace window, select the file name and then right click on the file, chooseAdd and Add filename.c.

    Then choose options on the same workspace window. Choose Device as NXPNXPLPC2148. Choose Linker in the category and select the override default. In that menu, choose

    Select othersoutput format as Intel extended. Choose config menu to select override default. In that box, choose the path IAR

    systems embedded workbench 4.0 kickstart ARM examples NXP

    LPC214XIAR-LPC-214XADCconfigurationflash.xcl.

  • 8/13/2019 Emb Lab Manual

    68/73

    MRK IT

    Right click on the workspace for rebuilding the program.FOR DOWNLOADING THE PROGRAM:

    In step 1 chooseCOM PortCOM 1

    Baud rate 9600

    Device LPC 2148

    Interface None

    Oscillator frequency12MHz

    In step 2 select Erase blocks used by Hex file; In step 3 browse the hex file. In step 4 select Verify after programming. Then click the Start button.

    PROCEDURE FOR XILINX:

    * Click on the Xilinx 9.1 and open the window create new source

    * Write the necessary codes and synthesis the program to verify the syntax.

    * Open synthesis implementation and assign the pin packages.

    * Implement design and generate program file.

    * Switch on the kit and open IMPACT and download the bit file and verify the output.

    PROGRAM:

    LED PROGRAM FOR ARM 7

    #include

    void LPC2148PLLInit(void);

    unsigned int i;

    void delay_ms()

    {

  • 8/13/2019 Emb Lab Manual

    69/73

    MRK IT

    int i,j;

    for(i=0;i

  • 8/13/2019 Emb Lab Manual

    70/73

    MRK IT

    IO1CLR=0x00010000 0))

    {

    loop_ctr--;

    }

    PLLCON_bit.PLLC = 1; /* Connect the PLL*/

    PLLFEED = 0xAA; /* Write to the PLL Feed register*/

  • 8/13/2019 Emb Lab Manual

    71/73

    MRK IT

    PLLFEED = 0x55;

    // VPBDIV = 0x00000001; /* Set the VPB frequency to one-half of the CPUclock */

    }VHDL PROGRAM FOR FPGA

    library IEEE;

    use IEEE.STD_LOGIC_1164.ALL;

    use IEEE.STD_LOGIC_ARITH.ALL;

    use IEEE.STD_LOGIC_UNSIGNED.ALL;

    entity abc is

    Port ( RESET : in STD_LOGIC;

    CLK_4M : in STD_LOGIC;

    COUNTER : out STD_LOGIC_VECTOR (3 downto 0));

    end abc;

    architecture Behavioral of abc is

    SIGNAL CLKDIV : STD_LOGIC_VECTOR(30 DOWNTO 0);

    SIGNAL CNTR : STD_LOGIC_VECTOR(3 DOWNTO 0);

    SIGNAL en0,en1,en2,en3 : STD_LOGIC;

    begin

    PROCESS(RESET,CLK_4M)

    BEGIN

    IF(RESET = '1') THEN

    CLKDIV '0');

    ELSIF(CLK_4M'EVENT AND CLK_4M = '1')THEN

    CLKDIV

  • 8/13/2019 Emb Lab Manual

    72/73

    MRK IT

    END IF;

    END PROCESS;

    PROCESS(RESET,CLK_4M,clkdiv)

    BEGIN

    IF(RESET = '1') THEN

    en1

  • 8/13/2019 Emb Lab Manual

    73/73

    end Behavioral;

    UCF( User Constraint File):

    I/O Pin I/O Direction Location

    Clock Input a8Reset Input J6Pin 0 Output p14Pin 1 Output t13Pin 2 Output r13Pin 3 Output p13