Controlling Pins on MPC56xx

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Controlling Pins on MPC56xx

ソリューションへジャンプ
1,947件の閲覧回数
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,437件の閲覧回数
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,438件の閲覧回数
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 件の賞賛
返信