安装codewarrior后,按照开发板调试了自带的汇编程序,由于不习惯汇编,自己用C语言写了自己的第一个example。
设置com2口作为程序下载口,使用class1协议,选择忽略在弹出的窗口,然后debug。
使用向导生成框架,添加初始化程序,和一个小延时程序,在主程序中点亮指示灯。
但怎么debug都不成功,最后在左边选择P&G ICD,然后编译成功。
#include <hidef.h> /* for EnableInterrupts macro */
#include <MC68HC908QT4.h> /* include peripheral declarations */
void init() {
CONFIG2 = 0x49;
CONFIG1 = 0x09;
OSCSTAT = 0x02;
DDRA = 0x10;
PTA = 0;
ADSCR = 0x21;
}
void delay(uchar t)
{
int i,j;
for(i=0;i<t;i++)
for( j=0;j<500;j++);
}
void main(void) {
EnableInterrupts; /* enable interrupts */
/* include your code here */
init();
for(;;) {
while ((ADSCR&0x80)==0);
PTA = 0x19;
delay(ADR);
PTA = 0;
delay(ADR);
__RESET_WATCHDOG(); /* feeds the dog */
} /* loop forever */
/* please make sure that you never leave this function */
}