?? g1.c
字號:
break;
}
}
return buf;
}
/**********************************************************
** 功能說明: 溫度補償函數(溫補參數占1個字節,補償電壓為mV單位,增益為DB/2單位等)
** 輸入參數: // buf3 類型:uchar :buf3=1,表示溫補參數占1個字節;buf3=2,表示溫補參數占2個字節
tempnb 類型:uchar :在溫補表中是第幾個參數,=1,是第1個參數;=2,第2個參數
// buf7 類型:uchar :在tn中參數是第幾個字節開始的參數
// buff: 類型:uchar :=0:溫度補償函數是△值,=1:溫度補償函數是實際值
** 輸出參數:
** 返 回 值: 無
** 引用函數:
**********************************************************/
uchar TEMP(uchar tempnb)
{
uchar i;
uchar buf;
char T[2];//EEPROM?D???è?μ
uchar buff;
uchar buf1;
uchar buf2;
uchar buf3;
buf=0;//è?1?±è????óD?á1?£??ò·μ??0
buf3=0;
for (i=0;i<tpnumb;i++)
{
dog();
T[0]=rrom(tempd+i);
if(i<tpnumb-1)
{
T[1]=rrom(tempd+i+1);
}
else
{
T[1]=T[0];
}
if (Prmter1.TEMP==T[0])
{
B[0]=rrom(tempcszd+tn*i+tempnb-1);
buf=B[0];
break;
}
if ((Prmter1.TEMP>T[0])&&(Prmter1.TEMP<T[1]))
{
buf3=1;
}
if ((Prmter1.TEMP>T[0])&&(Prmter1.TEMP>T[1])&&(T[1]<0x80)&&(T[0]>0x80))
{
buf3=1;
}
if(buf3==1)
{
B[0]=rrom(tempcszd+tn*i+tempnb-1);
B[1]=rrom(tempcszd+tn*(i+1)+tempnb-1);
buff=B[1]-B[0];
buf1=(Prmter1.TEMP-T[0]);
buf2=T[1]-T[0];
if (buff<0x80)
{
buf1=(B[1]-B[0])*buf1;
}
else
{
buf1=(B[0]-B[1])*buf1;
}
buf1=buf1/buf2;
buf1=buf1;
B[2]=B[0]+buf1;
buf=B[2];
break;
}
}
return buf;
}
/**********************************************************
** 功能說明: adc5308芯片輸出處理
** 輸入參數: addr 類型:uchar :芯片的管道號
buf 類型:uchar :輸入數據
** 輸出參數:
** 返 回 值: 無
** 引用函數:
*************************************************************/
//void DAC(uchar addr,uchar buf)
//{
// union buf_union dabuf1;
// union buf_union dabuf2;
// int k;
// if(buf>=249)//電壓不要超過4。9V
// {
// buf=249;
// }
// //TRISC3 = 0;
// //TRISC5 = 0;
// SSPSTAT = 0x40;
// SSPCON = 0x21;
// addr = addr & 0x07;
// dabuf1.buf2[1] = addr;
// dabuf1.buf2[0] = buf;
// dabuf2.buf1 = 0x8003;
// portb_wbuf = portb_wbuf | 0x02;
// PORTB = portb_wbuf;
// portb_wbuf = portb_wbuf & 0xfd;
// PORTB=portb_wbuf;
// SSPIF = 0;
//
// for(k=1;k>=0;k--)
// {
// SSPBUF = dabuf2.buf2[k];
// while(SSPIF == 0)
// {
// ;
// }
// SSPIF = 0;
// }
// portb_wbuf = portb_wbuf | 0x02;
// PORTB = portb_wbuf;
//
// dabuf1.buf1 = dabuf1.buf1 << 4;
//
// portb_wbuf = portb_wbuf & 0xfd;
// PORTB=portb_wbuf;
// SSPIF = 0;
//
// for(k=1;k>=0;k--)
// {
// SSPBUF = dabuf1.buf2[k];
// while(SSPIF == 0)
// {
// ;
// }
// SSPIF = 0;
// }
// portb_wbuf = portb_wbuf | 0x02;
// PORTB = portb_wbuf;
//}
/**********************************************************
** 功能說明: adc5318芯片輸出處理
** 輸入參數: addr 類型:uchar :芯片的管道號
dac_H 類型:uchar :輸入數據高字節
dac_L 類型:uchar :輸入數據低字節
** 輸出參數:
** 返 回 值: 無
** 引用函數:
*************************************************************/
void DAC(uchar addr,uchar dac_H,uchar dac_L)
{
union buf_union dabuf1;
union buf_union dabuf2;
union buf_union dabuf3;
int k;
// dog();
dabuf3.buf2[1]=dac_H;
dabuf3.buf2[0]=dac_L;
// if (dabuf3.buf1>=0x03dd)//電壓不要超過4。85V
// {
// dac_H=0x03;
// dac_L=0xdd;
// }
//TRISC3 = 0;
//TRISC5 = 0;
SSPSTAT = 0x40;
SSPCON = 0x21;
dabuf2.buf1 = 0x8003;
portb_wbuf = portb_wbuf | 0x02;
PORTB = portb_wbuf;
portb_wbuf = portb_wbuf & 0xfd;
PORTB=portb_wbuf;
SSPIF = 0;
for(k=1;k>=0;k--)
{
SSPBUF = dabuf2.buf2[k];
while(SSPIF == 0)
{
;
}
SSPIF = 0;
}
portb_wbuf = portb_wbuf | 0x02;
PORTB = portb_wbuf;
addr = addr & 0x07;
dabuf1.buf2[1] = addr;
dac_H=dac_H<<6;
dabuf1.buf2[0] = dac_H | (dac_L>>2);
dac_L=(dac_L<<2)&0x0c;//è??μμ?μí2??
dabuf1.buf1= (dabuf1.buf1 << 4)|dac_L;
portb_wbuf = portb_wbuf & 0xfd;
PORTB=portb_wbuf;
SSPIF = 0;
for(k=1;k>=0;k--)
{
SSPBUF = dabuf1.buf2[k];
while(SSPIF == 0)
{
;
}
SSPIF = 0;
}
portb_wbuf = portb_wbuf | 0x02;
PORTB = portb_wbuf;
return;
}
/**********************************************************
** 功能說明: 數據衰減設置(pe4302)
** 輸入參數: buf5 類型:uchar :衰減數據
** 輸入參數: buf7 類型:uchar :buf7=0X02為選擇PORTC1腳(DSALE2),buf7=0X20為選擇PORTD5腳(DSALE1)
** 輸出參數:
** 返 回 值: 無
** 引用函數:
************************************************************/
void ATT(uchar buf5,uchar buf7)
{
// if(buf5>=0x80)//衰減<0.
// {
// buf5=0;
// }
// if(buf5>=63)//衰減不可以超過31.5DB.
// {
// buf5=63;
// }
SSPSTAT = 0x40; //上升沿傳遞數據
SSPCON = 0x21;
if (buf7==0x02)
{
portc_wbuf = portc_wbuf | 0x02;
PORTC = portc_wbuf;
}
else
{
portb_wbuf = portb_wbuf | 0x08;
PORTB = portb_wbuf;
}
SSPIF = 0;
SSPBUF = buf5;
while(SSPIF == 0)
{
;
}
SSPIF = 0;
if (buf7==0x02)
{
portc_wbuf = portc_wbuf & 0xfd;
PORTC = portc_wbuf;
portc_wbuf = portc_wbuf | 0x02;
PORTC = portc_wbuf;
}
else
{
portb_wbuf = portb_wbuf & 0xf7;
PORTB = portb_wbuf;
portb_wbuf = portb_wbuf | 0x08;
PORTB = portb_wbuf;
}
}
/**********************************************************
** 功能說明: 28v檢測電壓處理函數
** 輸入參數:
** 輸出參數:
** 返 回 值: 無
** 引用函數:
************************************************************/
void CHECK_VTE28v()
{
union buf_union V28BUF;
Prmter1.V28U_L = adc_read(5);
Prmter1.V28U_H = 0;
V28BUF.buf1=Prmter1.V28U_L *11;
Prmter1.V28_L = V28BUF.buf2[0];
Prmter1.V28_H = V28BUF.buf2[1];
}
/**********************************************************
** 功能說明: 溫度檢測
** 輸入參數:
** 輸出參數:
** 返 回 值: 無
** 引用函數:
************************************************************/
void CHECK_TEMP()
{
uchar TEMP_adc;
uchar buf;
uchar buff;
TEMP_adc=adc_read(6);
temp_cnt++;
tempbuf=tempbuf+TEMP_adc;
if(temp_cnt>=TEMP_CNT)
{
tempbuf=tempbuf/temp_cnt;//取平均值
Prmter1.TEMPU_L =tempbuf & 0x00ff;
Prmter1.TEMPU_H= 0;
temp_cnt = 0x00;
tempbuf= 0x0000;
Prmter1.TEMP= (100*Prmter1.TEMPU_L)/51-60;
buf=tempinit-Prmter1.TEMP;
buff=-4;
if(tempcheck==0)
{
tempinit=Prmter1.TEMP;
tempcheck=1;
init_sign_ctl();
}
else if(tempcheck==1)
{
if((buf>4)&&(buf<0x80))
{
tempinit=Prmter1.TEMP;
init_sign_ctl();
}
else if((buf<buff)&&(buf>0x80))
{
tempinit=Prmter1.TEMP;
init_sign_ctl();
}
}
}
return;
}
/**********************************************************
** 功能說明: 選頻電路I輸出功率檢測
** 輸入參數:
** 輸出參數:
** 返 回 值: 無
** 引用函數:
************************************************************/
void CHECK_PWR1()
{
Prmter1.PWR1U = adc_read(0);
// Prmter1.PWR1 = Prmter1.PWR1U;
Prmter1.PWR1 = Prmter1.PWR1U/5-6+Prmter1.POFFSET1;
}
/**********************************************************
** 功能說明: 選頻電路2輸出功率檢測
** 輸入參數:
** 輸出參數:
** 返 回 值: 無
** 引用函數:
************************************************************/
void CHECK_PWR2()
{
Prmter1.PWR2U = adc_read(7);
//Prmter1.PWR2 = Prmter1.PWR2U;
Prmter1.PWR2 = Prmter1.PWR2U/5-6+Prmter1.POFFSET2;
}
/**********************************************************
** 功能說明: 功放管1第1級電流檢測
** 輸入參數: 無
** 輸出參數:
** 返 回 值: 無
** 引用函數:
**********************************************************/
void CHECK_id1()
{
uchar ID_adc;
ID_adc=adc_read(2);
id1_cnt++;
idbuf1=idbuf1+ID_adc;
if(id1_cnt>=ID_CNT)
{
idbuf1=idbuf1/id1_cnt;
Prmter1.ID1U =idbuf1 & 0x00ff;
Prmter1.ID1 =Prmter1.ID1U>>1;
id1_cnt = 0x00;
idbuf1= 0x0000;
}
return;
}
/**********************************************************
** 功能說明: 功放管1第2級電流檢測
** 輸入參數: 無
** 輸出參數:
** 返 回 值: 無
** 引用函數:
**********************************************************/
void CHECK_id2()
{
uchar ID_adc;
char buf1;
char buf2;
ID_adc=adc_read(1);
id2_cnt++;
idbuf2=idbuf2+ID_adc;
if(id2_cnt>=ID_CNT)
{
idbuf2=idbuf2/id2_cnt;
Prmter1.ID2U =idbuf2 & 0x00ff;
id2_cnt = 0x00;
idbuf2= 0x0000;
Prmter1.ID2 = Prmter1.ID2U>>1;
}
if ((Prmter1.ID2>5)&&(Prmter1.ID2<92))//0.1A~1.8A
{
buf2=0;
}
else
{
buf2=1;
}
// if ((Prmter1.ID1>2)&&(Prmter1.ID1<52))//0.04A~0.2A
// {
buf1=0;
// }
// else
// {
// buf1=1;
// }
if ((buf1==0)&&(buf2==0))
{
Prmter1.ID1ST=0;
}
else
{
Prmter1.ID1ST=1;
}
return;
}
/**********************************************************
** 功能說明: 功放管2第1級電流檢測
** 輸入參數: 無
** 輸出參數:
** 返 回 值: 無
** 引用函數:
**********************************************************/
void CHECK_id3()
{
uchar ID_adc;
ID_adc=adc_read(4);
id3_cnt++;
idbuf3=idbuf3+ID_adc;
if(id3_cnt>=ID_CNT)
{
idbuf3=idbuf3/id3_cnt;
Prmter1.ID3U=idbuf3 & 0x00ff;
Prmter1.ID3 = Prmter1.ID3U>>1;
id3_cnt = 0x00;
idbuf3= 0x0000;
}
return;
}
/**********************************************************
** 功能說明: 功放管II第2級電流檢測
** 輸入參數: 無
** 輸出參數:
** 返 回 值: 無
** 引用函數:
**********************************************************/
void CHECK_id4()
{
uchar ID_adc;
char buf3;
char buf4;
ID_adc=adc_read(3);
id4_cnt++;
idbuf4=idbuf4+ID_adc;
if(id4_cnt>=ID_CNT)
{
idbuf4=idbuf4/id4_cnt;
Prmter1.ID4U=idbuf4 & 0x00ff;
Prmter1.ID4 = Prmter1.ID4U>>1;
id4_cnt = 0x00;
idbuf4= 0x0000;
if ((Prmter1.ID4>5)&&(Prmter1.ID4<92))//0.1A~1.8A
{
buf4=0;
}
else
{
buf4=1;
}
// if ((Prmter1.ID3>2)&&(Prmter1.ID3<52))
// {
buf3=0;
// }
// else
// {
// buf3=1;
// }
if ((buf3==0)&&(buf4==0))
{
Prmter1.ID2ST=0;
}
else
{
Prmter1.ID2ST=1;
}
}
return;
}
/**********************************************************
** 功能說明: 鎖相環1的檢測
** 輸入參數:
** 輸出參數:
** 返 回 值: 無
** 引用函數:
************************************************************/
void CHECK_PLL1()
{
uchar buf11;
buf11 = PORTB & 0x10;//1
if(buf11)
{
if(PLL_count11>=20)
{
Prmter1.PLL_STATE1 = 0x01;
PLL_count11=20;
PLL_count1=0;
}
PLL_count12=0;
PLL_count11++;
}
else
{
if(PLL_count12>=20)
{
Prmter1.PLL_STATE1 = 0x00;
PLL_count12=20;
//PLL_count1=0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -