Jacob Francis

Help Controlling onboard MCF51JF LEDs - please look

Discussion created by Jacob Francis on Jun 10, 2012
Latest reply on Mar 21, 2015 by Ben Carter

I am learning to use the MCF51JF128 board and am attempting to write a simple program to control the onboard green and orange LEDs on the MCF51JF128 board.  (on my own - not a school project)


I can not for the life of me understand what I am missing that is keeping them from functioning.  I have studied the quick start demo that freescale provides, but it seems needlessly complicated for my purposes. (tons of linked files throwing errors when trying to prune it down).


I currently have the code attached below (Don't worry - it's short) .  What am I missing that would make the LEDs not respond?  They respond correctly in the quickstart demo program, but I don't know what I am missing here.



* LEDs.h
* Created on: Apr 4, 2011
* Author: B23243

#ifndef LEDS_H_
#define LEDS_H_

#define LED1_ON PTA_D &= 0xFE
#define LED2_ON PTC_D &= 0xDF

#define LED1_OFF PTA_D |= 0x01
#define LED2_OFF PTC_D |= 0x20

#define LED1_TOG if(PTA_D & 0x01) PTA_D &= 0xFE; else PTA_D |= 0x01
#define LED2_TOG if(PTC_D & 0x20) PTC_D &= 0xDF; else PTC_D |= 0x20


#endif /* LEDS_H_ */




#include "common.h" /* include peripheral declarations */
#include <LEDs.h> /* code to toggle pins connected to LEDs */

/* function prototypes */
void disable_watchdog(void);
void LEDs_Init(void);

/* variables*/
unsigned char state;

/* functions */
void disable_watchdog(void)

void LEDs_Init(void)
    MXC_PTAPF4 = ((MXC_PTAPF4 & 0xF0) | 0x01);//Select PTA0 GPIO
    MXC_PTCPF2 = ((MXC_PTCPF2 & 0x0F) | 0x10);//Select PTC5 GPIO

    PTA_DD = 0x01; //Configure PTA0 as output
    PTC_DD = 0x20; //configure PTC5 as output


/* main */
void main(void) {
    /* include your code here */


    for(;:smileywink: {

    } /* loop forever */
    /* please make sure that you never leave main */