turning on single led

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

turning on single led

1,747 Views
g_mani
Contributor I
i need code for turn on led 0 or led 1 in mcf 5329. any one please help me. its urgent.
Labels (1)
0 Kudos
2 Replies

256 Views
mnorman
NXP Employee
NXP Employee
LED0 and LED1 on the M5329EVB are controlled by a latch on the MCF5329 external bus.  The sample code on the web shows an example of using this latch (see the USB sample project).  You can find the sample code here:
http://www.freescale.com/webapp/sps/download/license.jsp?colCode=MCF532XSC&location=null&fpsp=1

Here is a snippet of code that initialized the latch.  You can write data to the latch to control the LEDs in a similar way.

/********************************************************************/
void
latch_init (void)
{
    /* Initialization for the latch on the fire engine (U6) */
   
    /* Initialize TIN3 as a GPIO output to enable the write
       half of the latch */
    MCF_GPIO_PAR_TIMER = 0x00;
    MCF_GPIO_PDDR_TIMER = 0x08;
    MCF_GPIO_PCLRR_TIMER = 0x0;
   
     /* Initialize latch to drive signals to inactive states */
    *((uint16 *)(LATCH_ADDRESS)) = 0xFFFF;              

}
/********************************************************************/

-mnorman


Message Edited by mnorman on 2007-11-13 04:13 PM
0 Kudos

256 Views
SimonMarsden_de
Contributor II
Hi

You don't mention which board you're using, so your mileage may vary...

On the Freescale M5329EVB evaluation board, I believe there's an LED wired to the TIMER3 pin in the TIMER port.

You need to do two things:

(a) Configure the TIMER port so that the pin is a General-Purpose Output (It could also be an input, or be used for non-I/O purposes like a UART 2 receive pin)

    /* Pin assignments for port TIMER
           Pins are all GPIO outputs
    */
    MCF_GPIO_PDDR_TIMER =
                          MCF_GPIO_PDDR_TIMER_PDDR_TIMER3  |
                          MCF_GPIO_PDDR_TIMER_PDDR_TIMER2  |
                          MCF_GPIO_PDDR_TIMER_PDDR_TIMER1  |
                          MCF_GPIO_PDDR_TIMER_PDDR_TIMER0;
    MCF_GPIO_PAR_TIMER = 0;


(b) Change the state of the pin to turn the LED on or off. The following loop would flash it:

    /* Sample code: Loop to flash LED */
    while (1) {
        MCF_GPIO_PODR_TIMER ^= MCF_GPIO_PODR_TIMER_PODR_TIMER3;
        for (i = 0; i < 500000; i++)
            asm ( "nop" );
    }

(The "nop" instruction just prevents the compiler from optimising out the delay loop between flashes)


Hope this helps


Simon
0 Kudos