/* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dp256b"
#define CRYSTAL 16000000 /*8Mhz crystal*/
#define LOCK 8
#define PLLSEL 0x80 //; use PLL for system clocks.
#define Eclock 16000000// ; final E-clock frequency (PLL)
#define RefClock 1000000
#define REFDVVal (CRYSTAL/RefClock)-1
#define SYNRVal (Eclock/RefClock)-1
byte c;
/****************************************************************************
* init_PLL() -
*
* To initialize the PLL for system use.
*****************************************************************************/
void init_PLL(void)
{
REFDV = REFDVVal; // set the REFDV register to give us a 1.0 MHz reference.
SYNR = SYNRVal; // set the SYNR register to give us a 8.0 MHz E-clock.
asm nop // nops required for PLL stability.
asm nop
asm nop
asm nop
while ((CRGFLG&LOCK)==0); // wait here till the PLL is locked.
CLKSEL|= PLLSEL; // switch the bus clock to the PLL.
}
/**************************************************************************
* SCI initialization *
***************************************************************************/
void init_SCI() {
SCI0BD=Eclock/16/9600;
SCI0CR2_RE=1;
SCI0CR2_TE=1;
SCI0CR2_RIE=1;
SCI0CR2_TCIE=1;
SCI0CR2_SCTIE=1;
}
/**************************************************************************
* Timer initialization *
***************************************************************************/
void init_Timer() {
TSCR2=0x87; //Enable main timer overflow interrupt
COPCTL =0; // disable cop
TSCR1=0xA0; //Enable main timer functionality
}
#pragma CODE_SEG __NEAR_SEG NON_BANKED
#pragma TRAP_PROC
void interrupt SCI0_REC(void){
c = SCI0SR1;
c = SCI0DRL;
PORTB=c;
}
#pragma CODE_SEG DEFAULT
/**************************************************************************
* Main routine *
***************************************************************************/
void main(void) {
/* put your own code here */
//unsigned int i;
// init_PLL();
init_SCI();
//init_Timer();
EnableInterrupts;
DDRB = 0xFF;
for(;;)
{
; // Trans
/* while(!SCI0SR1_TDRE);
SCI0DRL = 0x30;
while(!SCI0SR1_TC);
while(!SCI0SR1_TDRE);
SCI0DRL = 0x31;
while(!SCI0SR1_TC);
//while(!SCI0SR1_RDRF);
//PORTB=SCI0DRL;
if(TCNT==0xff00)
PORTB++;
if(TFLG2_TOF==1)
i=TCNT;
/*i=0xFFFF;
PORTB=0x0F;
while((i--)!=0);
i=0xFFFF;
PORTB=0xF0;
while((i--)!=0);*/
} /* wait forever */
}
作者: dragonfei 时间: 2005-3-24 11:15
谢谢yunfeng的帮助
作者: fjczd 时间: 2009-2-4 13:42
多谢老大的回复
作者: fjczd 时间: 2009-2-6 17:24
void main(void)
{
/* Write your local variable definition here */
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
PE_low_level_init();
/*** End of Processor Expert internal initialization. ***/
for(;;){
err = AS1_RecvChar(&ch);
AS1_SendChar(0x55);
}
上边使用PE生成的,仅供参考
作者: xueqixuan_1985 时间: 2009-2-7 23:16
那个监控程序只有邵老师那里提供的开发板才有,应该是事先用BDM在里面写好的,有了监控程序就可以用串口来烧程序而不用BDM
作者: fjczd 时间: 2009-2-12 11:41
自己做的板子,用bdm不是就很好吗
为什么非要用串口呢
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) |
Powered by Discuz! 7.0.0 |