Controlling Pins on MPC56xx

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Controlling Pins on MPC56xx

跳至解决方案
2,473 次查看
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.

 


标签 (1)
标记 (3)
0 项奖励
回复
1 解答
1,963 次查看
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 项奖励
回复
1 回复
1,964 次查看
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 项奖励
回复