在线时间4 小时
UID3155971
注册时间2015-8-6
NXP金币0
该用户从未签到
新手上路
- 积分
- 31
- 最后登录
- 2015-9-1
|
楼主 |
发表于 2015-8-11 10:44:52
|
显示全部楼层
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
#include "mc9s08pt16.h"
#include "gpio.h"
unsigned int i;
void init_system(void) /* 配置系统时钟 */
{
PMC_SPMSC1=0x5C; //Force an MCU reset when an enabled low-voltage detect event occurs.
PMC_SPMSC2=0x00;
SYS_SRS=0x82; //POR caused reset.Reset caused by LVD trip or POR.
SYS_SOPT1=0x88; //SCI0 RxD and TxD are mapped on PTA2 and PTA3.PTA4/ACMPO/BKGD/MS as BKGD function.PTA5/IRQ/TCLK0/RESET pin functions as PTA5, IRQ, or TCLK0.
ICS_OSCSC=0x94; //使用外部振荡器时钟
while (!ICS_OSCSC_OSCINIT) {} //等待外部参考时钟稳定
ICS_C1=ICS_C1_CLKS1_MASK | ICS_C1_RDIV1_MASK |ICS_C1_RDIV0_MASK; //选择外部时钟控制总线频率,晶振频率8M
ICS_C2=0x20; //2分频,总线频率4M
}
void initgpio(void);
void init_timer(void);
void main(void)
{
DisableInterrupts; /*置位中断屏蔽标志位*/
WDOG_CS1=0;
initgpio(); //调试时用的gpio口
init_system();
led0=1;
led2=1;
for( i=0; i<100;i++) /* 延时一段时间 */
{
asm ("NOP");
}
led1=1;
EnableInterrupts; /*清除中断屏蔽标志位*/
// init_timer();
while(1)
{
}
/* include your code here */
// for(;;) {
// __RESET_WATCHDOG(); /* feeds the dog */
// } /* loop forever */
/* please make sure that you never leave main */
}
interrupt VectorNumber_Vmtim0 void TIMER_isr(void)
{
if(MTIM0_SC_TOF==1)
MTIM0_MOD=0xff;
// i++;
// if(i>=1000)
// led1=1;
led1=~led1;
for(i=0; i<1;i++) // 延时一段时间
{
asm ("NOP");
}
}
* GPIO.c
*
* Created on: Jul 28, 2015
* Author: Administrator
*/
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
#include "mc9s08pt16.h"
//#include <tsi.h>
#include "gpio.h"
void initgpio(void)
{
PORT_PTAOE|= PORT_PTAOE_PTAOE0_MASK | PORT_PTAOE_PTAOE1_MASK | PORT_PTAOE_PTAOE5_MASK;
PORT_PTAPE|= PORT_PTAPE_PTAPE0_MASK | PORT_PTAPE_PTAPE1_MASK | PORT_PTAPE_PTAPE5_MASK;
PORT_PTBOE|= PORT_PTBOE_PTBOE5_MASK;
PORT_PTBPE|= PORT_PTBPE_PTBPE5_MASK;
// led0=0;
//led1=0;
}
以上是我的主程序
|
|