跨届大侠
北京龙邱智能科技有限公司
- 积分
- 10332
- 威望
- 2905
- 贡献
- 6151
- 兑换币
- 4515
- 注册时间
- 2008-6-7
- 在线时间
- 638 小时
|
本帖最后由 chiusir 于 2011-11-4 15:44 编辑
龙丘奉献MPC5604B测试程序一个,新手熟悉下32位的编程风格
/*
/********************************************************
【编 写】龙丘
【dev.env.】Code Warrior 2.9
【Target 】MPC5604B
【内部晶振】 khz
【外部晶振】8MHz
【总线频率】64MHz
LED闪烁测试
*/
#include "MPC5604B_M27V.h"
void initModesAndClock(void) {
ME.MER.R = 0x0000001D; /* Enable DRUN, RUN0, SAFE, RESET modes */
/* Initialize PLL before turning it on: */
/* Use 1 of the next 2 lines depending on crystal frequency: */
CGM.FMPLL_CR.R = 0x02400100; /* 8 MHz xtal: Set PLL0 to 64 MHz */
/*CGM.FMPLL_CR.R = 0x12400100;*/ /* 40 MHz xtal: Set PLL0 to 64 MHz */
ME.RUN[0].R = 0x001F0074; /* RUN0 cfg: 16MHzIRCON,OSC0ON,PLL0ON,syclk=PLL */
ME.RUNPC[1].R = 0x00000010; /* Peri. Cfg. 1 settings: only run in RUN0 mode */
ME.PCTL[68].R = 0x01; /* MPC56xxB/S SIUL: select ME.RUNPC[0] */
ME.PCTL[72].R = 0x01; /* MPC56xxB/S EMIOS 0: select ME.RUNPC[0] */
/* Mode Transition to enter RUN0 mode: */
ME.MCTL.R = 0x40005AF0; /* Enter RUN0 Mode & Key */
ME.MCTL.R = 0x4000A50F; /* Enter RUN0 Mode & Inverted Key */
while (ME.GS.B.S_MTRANS) {} /* Wait for mode transition to complete */
/* Note: could wait here using timer and/or I_TC IRQ */
while(ME.GS.B.S_CURRENTMODE != 4) {} /* Verify RUN0 is the current mode */
}
void delayms(int ms)
{
int ii,jj;
if (ms<1) ms=1;
for(ii=0;ii<ms;ii++)
for(jj=0;jj<3338;jj++); //40MHz--1ms
}
int main(void)
{
volatile int i = 0;
initModesAndClock();
SIU.PCR[70].R = 0x0203;
SIU.PCR[71].R = 0x0203;
SIU.PCR[68].R = 0x0203;
SIU.PCR[69].R = 0x0203;
/* Loop forever */
while(1)
{
i++;
//PEO=0;
SIU.GPDO[71].R=0; //LED亮
SIU.GPDO[70].R=0;
SIU.GPDO[69].R =0;
SIU.GPDO[68].R =0;
//SIU.PCR[70].R = 0x0604;
//=0X00000000;
delayms(200);
//PEO=0XFF;
SIU.GPDO[71].R=1; //LED灭
SIU.GPDO[70].R=1;
SIU.GPDO[69].R =1;
SIU.GPDO[68].R =1;
//SIU.PCR[70].R = 0x0903;
delayms(200);
}
} |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|