Controlling Pins on MPC56xx

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

Controlling Pins on MPC56xx

Jump to solution
1,607 Views
rayhall
Contributor V

I am new to all things Freescale. I am trying to learn by starting with the most basic project. This is to flash a LED. This is my code.

 

#include "MPC5633M.h"

 

void Delay(void){

  uint16_t x;

  uint16_t y;

 

  for(x=0;x<50;x++) {

      for(y=0;y<1000;y++) {

         

      }

  }

}

 

int main(void) {

    

  SIU.PCR[188].R = 0x0200;  /* Enable pin for LED1 (EMIOS9) as output*/ 

 

 

  /* Loop forever */

  for (;;) {

    

    Delay();

    SIU.GPDO[2].R &= 0x07000000;  /* Enable LED1*/

    Delay();

    SIU.GPDO[2].R |= 0x08000000;  /* Disable LED1*/   

  }

}

 

It does not work. Good reasion for this is the magic numbers like 0x0200, 0x07000000, 0x08000000. I have no idea what these are, or how to set them correctly.

 

Ray.

 


Labels (1)
Tags (3)
0 Kudos
1 Solution
1,097 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi Ray,

You may use just a following code to control single pin

SIU.GPDO[188].R  = 0x1;                               /* set GPIO[188] */

SIU.GPDO[188].R = 0x0;                              /* clear GPIO[188] */

SIU.GPDO[188].R ^= 0x1;                             /* toggle GPIO[188] */

The SIU.PCR[188].R = 0x0200; sets the pin for GPIO function and enable output buffer, so you can control the pin by above codes.

BR,

Petr

View solution in original post

0 Kudos
1 Reply
1,098 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi Ray,

You may use just a following code to control single pin

SIU.GPDO[188].R  = 0x1;                               /* set GPIO[188] */

SIU.GPDO[188].R = 0x0;                              /* clear GPIO[188] */

SIU.GPDO[188].R ^= 0x1;                             /* toggle GPIO[188] */

The SIU.PCR[188].R = 0x0200; sets the pin for GPIO function and enable output buffer, so you can control the pin by above codes.

BR,

Petr

0 Kudos