对旧程序作了修改,用在一个延伸机型上面,芯片是HT46R48A,编译无误,但是在用合泰HT-ICE仿真的时候总是会出现以下错误:Error(L1038):ROM(区块*)对段落[email=]'@KeySub'[/email]配置存储器空间(大小为09FH)失败,此段位于'C:\Documents and Settings\Administrator\桌面\复件 md-1011c10模式减少修改中1\1011D.OBJ'文件
错误总数:1 警告总数:0
'1011d' - Total 1 error(s), 0 warning(s)
以下是源程序:
/*
PA_WAKE-UP =0X00 0:NO WAKE-UP
PA-PULL-HIGH=0XC0 0:NO PULL-HIGH
PB-PULL-HIGH=0X07 0:NO PULL-HIGH
PC-PULL-HIGH=0X00
PD-PULL-HIGH=0
PWM=DISABLE
PA3-PFD=ENABEL
LVR=ENABEL
WDT=ENABEL
CLRWDT=ONE CLEAR INSTRUCTION
WDT CL=T1
*/
#include "HT46C48A.H"
//#include "HT46F48E.h"
#define uchar unsigned char
#define ushort unsigned long
#pragma vector timer0 @ 0x08
#pragma vector intr0 @ 0x04
//=========IO 定义
#define P_MOTO1 _pa6
#define P_MOTO2 _pa7
//#define P_KEY1 _pb2
//#define P_KEY2 _pb1
//#define P_KEY3 _pb0
#define P_KEY1 _pb2
#define P_KEY2 _pb1
#define P_KEY3 _pb0
#define P_KEY4 _pb3
#define P_BZ _pa3
#define P_LED1 _pd0
#define P_LED2 _pa2
#define P_LED3 _pa1
#define P_COM1 _pc0
#define P_COM2 _pc1
#define EEI _eei
#pragma rambank0
bit F_ON_OFF;
bit F_ZERO,F_EINT;
bit F_MOTO_L,F_MOTO_R,F_MOTO_L_F,F_MOTO_R_F; //左右振动使能
bit F_KEY_ST;
bit F_TIME_1MS;
bit F_BZ_F,F_BZ_H;
bit F_OUT_E;
//bit F_TEMP_F,F_TEMP_F1,F_TEMP_F2;
bit F_TIME500MS;
bit F_LED_2S;
bit F_TEMP_F1;
bit F_TEMP_F;
bit F_TEMP_F2;
uchar GateOffTime1,GateOffTime2;
uchar MotoVi,MotoViBuff;
uchar ModeM;
uchar MotoViS;
uchar KeyTime;
uchar Time1ms;
uchar MotoMode;
uchar BzS,BzS1;
uchar Timer2; //定时
uchar OutS,OutTemp,OutTemp1;
uchar AutoMode;
uchar StTime;
uchar LedS,Sunmer;
ushort Led2s;
ushort Timer1;
ushort OutTime,OutTimeBuff,OutTimeBuffV;
ushort MotoTime;
ushort Time500ms,BzTime,BzTimeV;
const uchar MotoViTa[]={0,20,24,29,33,37,41,44,48}; //分9级
const uchar BcdTal[]={0x7e,0x22,0x6d,0x67,0x33,0x57,0x5f,0x62,0x7f,0x77};
void Sys_init();
void Ram_init();
void TimeSub();
void KeySub();
void MotoSub();
void BzSub(uchar s,ushort d);
void LedSub();
void delayus(uchar s);
void MotoOutS(uchar rnum,uchar lnum,ushort dtime,uchar n);
void MotoOutS2();
void MotoOutS1();
void MotoOutS_L(uchar n1,uchar dl1,uchar dl2);
void MotoOutS_R(uchar n1,uchar dl1,uchar dl2);
void MotoOutM1(ushort s);
void MotoOutM2();
void MotoOutS2();
void MotoOutS1();
void MotoOutS_B(uchar n1,uchar dl1,ushort dl2);
//*****************************************************************************************************
// 外部中断,,主要是零点检测
// 上升沿
//
//
//*****************************************************************************************************
void intr0()
{
F_ZERO=1; //马达1零点到
// F_TIME_10MS=1;
}
//*****************************************************************************************************
// 定时器中断,,200us一次
// 主要是:定时功能,,可控硅输出强度,可控硅从下半周到负半周定时10ms
// BZ输出功能
//
//
//
//*****************************************************************************************************
void timer0()
{
//_tmr=55;
#asm
clr wdt
#endasm
if(F_ON_OFF)
{
//==============================可控硅门级1关
if(F_MOTO_L_F)
{
if(++GateOffTime1>=3) //可控硅驱动脉宽600US
{
GateOffTime1=0;
P_MOTO1=1;
F_MOTO_L_F=0;
}
}
//==============================可控硅门级2关
if(F_MOTO_R_F)
{
if(++GateOffTime2>=3) //可控硅驱动脉宽600US
{
GateOffTime2=0;
P_MOTO2=1;
F_MOTO_R_F=0;
}
}
//==============================可控硅输出大小
if(F_ZERO)
{
if(++MotoVi>=48) //输出强度变量,,
{
F_ZERO=0;
MotoVi=MotoViBuff;
if(F_MOTO_L)
{
F_MOTO_L=0;
F_MOTO_L_F=1;
P_MOTO1=0;
}
if(F_MOTO_R)
{
F_MOTO_R=0;
F_MOTO_R_F=1;
P_MOTO2=0;
}
}
}
//================================================
}
else
{
P_MOTO1=1;
P_MOTO2=1;
}
//========================================================
// 1MS的标志
if(++Time1ms>=5)
{
Time1ms=0;
F_TIME_1MS=1;
// _pa2=!_pa2;
}
}
//*******************************************************************************************************
//
// 主程序:循环跑(可控硅控制,时间程序,按键程序,LED显示程序,马达输出或加热)
//
//
//
//*******************************************************************************************************
void main()
{
Sys_init();
Ram_init();
//Time1ms=1;
BzSub(2,200);
while(1)
{
if(F_TIME_1MS)
{
F_TIME_1MS=0;
TimeSub();
KeySub();
LedSub();
MotoSub();
}
}
}
//*******************************************************************************************************
//
//
//
// 系统初始化,,IO,,定时,,外部中断
//
//*******************************************************************************************************
void Sys_init()
{
_pbc=0x00;
_pb=0;
_pac=0x20;
_pcc=0;
_pdc=0;
P_COM1=1;
P_COM2=1;
P_LED1=1;
P_LED2=1;
P_LED3=1;
_pa6=1;
_pa7=1;
P_BZ=0;
//------------
_tmrc=0x82; //4M/32*(255-130)=1MS
_tmr=55;
_eti=1;
_emi=1;
_ton=1;
_eei=0;
}
//*******************************************************************************************************
//
//
// 内存初始
//
//
//*******************************************************************************************************
void Ram_init()
{
//_bp=0;
_mp=0xA8;
do{
_iar=0;
_mp++;
}while(_mp^0xff);
_iar=0;
//F_ON_OFF=0;
// F_ZERO=0;
// F_EINT=0;
// F_MOTO_L=0;
// F_MOTO_R=0;
// F_MOTO_L_F=0;
// F_MOTO_R_F=0;
// F_KEY_ST=0;
// F_TIME_1MS=0;
// F_BZ_F=0;
// F_BZ_H=0;
// F_OUT_E=0;
// F_LED_2S=0;
// F_TEMP_F=1;
// F_TEMP_F1=1;
// F_TEMP_F2=1;
// StTime=0;
// AutoMode=4;
// GateOffTime1=0;
// GateOffTime2=0;
MotoViS=3;
MotoVi=MotoViBuff=MotoViTa[3];
// KeyTime=0;
// Time1ms=0;
MotoMode=1;
BzS=1;
// BzTime=0;
// Timer2=0;
// OutS=0;
// OutTemp=0;
// Timer1=0;
// OutTime=0;
// OutTimeBuff=0;
// MotoTime=0;
// LedS=0;
// Time500ms=0;
// Led2s=0;
ModeM=1;
}
//*******************************************************************************************************
//
//
// 时间处理,开机定时6分
//
//
//*******************************************************************************************************
void TimeSub()
{
if(F_ON_OFF) //开机定时10分
{
if(++Timer1>60000)
{
Timer1=0;
if(++Timer2>=10)
{
F_ON_OFF=0; //关机
Timer2=0;
Ram_init();
BzSub(3,500);
}
}
}
//=======================================蜂鸣器处理
if(F_BZ_F)
{
if(F_BZ_H)
{
if(++BzTime>BzTimeV) //蜂鸣器响的时间
{
F_BZ_H=0;
P_BZ=0;
BzTime=0;
}
}
else
{
if(++BzTime>BzTimeV) //蜂鸣器停的时间
{
BzTime=0;
if(--BzS>0)
{
F_BZ_H=1;
P_BZ=1;
}
else
F_BZ_F=0;
}
}
}
//--------------------------------------------OUT TIME
if(F_ON_OFF)
{
if(++OutTime>OutTimeBuff) //电机输出的时间
{
OutTime=0;
F_OUT_E=1; //电机输出使能
}
}
if(++Time500ms>=500) //0.5S时间标志
{
Time500ms=0;
F_TIME500MS=!F_TIME500MS;
}
//======================================数码管转换显示2S
if(F_LED_2S)
{
if(++Led2s>2000)
{
Led2s=0;
F_LED_2S=0;
}
}
}
//*******************************************************************************************************
//
// 这里主要是马达振动多久停多久的输出模式
//
// 手动模式1-5,,,自动模式6
//
//*******************************************************************************************************
void MotoSub()
{
if(F_OUT_E)
{
F_OUT_E=0;
if(F_ON_OFF==0)return;
switch(AutoMode)
{
case 1:
{
switch(MotoMode)
{
case 1:{MotoOutS(2,2,180,10);}break;
// case 2:{MotoOutS(3,3,140,5);}break;
case 2:{MotoOutS(5,5,160,6);}break;
// case 4:{MotoOutS(3,3,120,6);}break;
case 3:{MotoMode=1;}break;
default:break;
}
}break;
case 2:
{
switch(MotoMode)
{
case 1:{MotoOutS(1,1,220,20);}break;
case 2:{MotoOutS(5,5,220,5);}break;
case 3:{MotoOutS(1,1,140,20);}break;
case 4:{MotoOutS(5,5,140,6);}break;
case 5:{MotoMode=1;}break;
default:break;
}
}break;
case 3:
{
switch(MotoMode)
{
case 1:{MotoOutS1();}break;
case 2:{MotoOutS2();}break;
case 3:{MotoMode=1;}break;
default:break;
}
}break;
case 4:
{
switch(MotoMode)
{
case 1:{MotoOutS(3,1,160,10);}break;
case 2:{MotoOutS(1,3,160,10);}break;
case 3:{MotoOutS(1,1,160,15);}break;
case 4:{MotoOutS(2,2,160,15);}break;
case 5:{MotoMode=1;}break;
default:break;
}
}break;
case 5:
{
//---------------------------------------------------------
switch(MotoMode)
{
case 1:{MotoOutS(2,2,180,4);}break;
case 2:{MotoOutS(3,3,120,4);}break;
case 3:{MotoOutS(2,2,180,4);}break;
case 4:{MotoOutS(3,3,120,4);}break;
case 5:{
MotoOutS_B(20,120,60);
}break;
case 6:{MotoOutS_B(16,160,60);}break;
case 7:{MotoOutS_B(12,180,60);}break;
case 8:{MotoOutS_B(10,220,60);}break;
case 9:{MotoOutS_B(20,120,60);}break;
case 10:{MotoOutS_B(16,160,60);}break;
case 11:{MotoOutS_B(12,180,60);}break;
case 12:{MotoOutS_B(10,230,60);}break;
case 13:{MotoOutS(16,16,120,2);}break;
case 14:{MotoOutS(12,12,80,7);}break;
case 15:{MotoOutS(5,5,100,2);}break;
case 16:{MotoOutS_B(20,100,500);}break;
case 17:{MotoOutS_B(20,100,200);}break;
case 18:{MotoOutS(5,5,100,2);}break;
case 19:{MotoOutS_B(20,100,500);}break;
case 20:{MotoOutS_B(20,100,200);}break;
case 21:{MotoOutS(15,15,100,1);}break;
case 22:{MotoOutS_B(15,100,500);}break;
case 23:{MotoOutS(15,15,100,1);}break;
case 24:{MotoOutS_B(15,100,500);}break;
case 25:{MotoOutS(15,15,100,1);}break;
case 26:{MotoOutS_B(15,100,500);}break;
case 27:{MotoOutS_R(30,100,500);}break;
case 28:{MotoOutS_B(30,100,500);}break;
case 29:{MotoOutS_L(30,100,500);}break;
case 30:{MotoOutS_B(30,100,500);}break;
case 31:{MotoOutS1();}break;
case 32:{MotoOutS2();}break;
case 33:{MotoOutS(10,10,140,2);}break;
case 34:{MotoOutS(10,10,120,2);}break;
case 35:{MotoOutS(12,12,100,2);}break;
case 36:{MotoOutS(3,3,270,2);}break;
case 37:{MotoOutS(3,3,220,2);}break;
case 38:{MotoOutS(3,3,140,3);}break;
case 39:{MotoOutS(15,15,100,2);}break;
case 40:{MotoOutS(15,15,120,2);}break;
case 41:{MotoOutS(18,18,140,2);}break;
case 42:{MotoOutS(3,3,140,3);}break;
case 43:{MotoOutS(3,3,220,2);}break;
case 44:{MotoOutS(3,3,270,2);}break;
case 45:{MotoOutS(18,18,120,4);}break;
case 46:{MotoOutS(5,5,100,2);}break;
case 47:{MotoOutS_B(20,100,500);}break;
case 48:{MotoOutS_B(20,100,200);}break;
case 49:{MotoOutS(5,5,100,2);}break;
case 50:{MotoOutS_B(20,100,500);}break;
case 51:{MotoOutS_B(20,100,200);}break;
case 52:{MotoOutS(15,15,100,1);}break;
case 53:{MotoOutS_B(15,100,500);}break;
case 54:{MotoOutS(15,15,100,1);}break;
case 55:{MotoOutS_B(15,100,500);}break;
case 56:{MotoOutS(15,15,100,1);}break;
case 57:{MotoOutS_B(15,100,500);}break;
case 58:{MotoOutS_R(30,100,500);}break;
case 59:{MotoOutS_B(30,100,500);}break;
case 60:{MotoOutS_L(30,100,500);}break;
case 61:{MotoOutS_B(30,100,500);}break;
case 62:{MotoOutS1();}break;
case 63:{MotoOutS2();}break;
case 64:{MotoOutS(3,3,270,2);}break;
case 65:{MotoOutS(3,3,220,2);}break;
case 66:{MotoOutS(3,3,140,3);}break;
case 67:{MotoOutS(10,10,140,2);}break;
case 68:{MotoOutS(10,10,120,2);}break;
case 69:{MotoOutS(12,12,100,2);}break;
case 70:{MotoOutS(1,1,120,200);}break;
case 71:{MotoOutS1();}break;
case 72:{MotoOutS2();}break;
case 73:{MotoMode=1;}break;
default:break;
}
//--------------------------------------------------------------
}break;
default:break;
}
}
} |