PIC16C74 MCU display program
/*******************************************
************PIC16C74 MCU Control**************
********************************************/
#include
#include
#include
#defineucharunsignedchar//
#defineuintunsignedint//
//---------------------------------------
#defineBIAS0X50//1/2 bias, 4 back pole
#defineRC2560X30//System clock is selected as on-chip RC oscillator
#defineWDTDIS10X0A//Disable WDT overflow flag output
#defineTIMERDIS0X08//Time base output disable
#defineSYSEN0X02//Open the system clock
#defineLCDON0X06//Open bias generator
#defineSYSDIS0X00//Turn off the system clock and bias generator
#defineKEY_UPRB7//
#defineKEY_DOWNRB6//
#defineKEY_SETRB5//
//--------------------------------------
//staticunsignedcharKeyV, TempKeyV; / / key value
Unsignedcharbuf0, buf1, buf2, buf3, buff;//
Unsignedcharbuf[4];//
Unsignedchark,data,sreg,disppoint;//
Unsignedinti;//
Consttable[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xd8,0x80,0x90};//
//*********************************
/*delay function*/
//*********************************
Voiddelay_10ms()//
{uintj;//
For(j=0;j<1000;j++)//
{;}//
}//
//*********************************
Voiddelay_1ms()//
{uintj;//
For(j=0;j<100;j++)//
{;}//
}//
//**********************************
Voiddelay1s()//delay 1S
{
Uchari;//
Uintj;//
For(i=0;i<10;i++)//
For(j=0;j<1300;j++);//
}//
//**********************************
/ / button waiting program
//**********************************
Voidkeywait()//
{
While((PORTB&0xF0)!=0xF0)//
{;}//
}//
//********************************
//********************************
Voidbuf_initial()//
{
Buf0=0x00;//
Buf[0]=buf0;//
Buf1=0x00;//
Buf[1]=buf1;//
Buf2=0x00;//
Buf[2]=buf2;//
Buf3=0x00;//
Buf[3]=buf3;//
Sreg=0x00;//
}//
//**********************************
Voidput_num(charc)
{
PORTC=table[c&0x0f];//
}
//**********************************
Voiddisplay()//
{
Disppoint=0;//
Put_num(buf[disppoint]);//
RC0=0;//
Delay_1ms();//
RC0=1;//
Disppoint++;//
Put_num(buf[disppoint]);//
RC1=0;//
Delay_1ms();//
RC1=1;//
Disppoint++;//
Put_num(buf[disppoint]);//
RC2=0;//
Delay_1ms();//
RC2=1;//
Disppoint++;//
Put_num(buf[disppoint]);//
RC3=0;//
Delay_1ms();//
RC3=1;//
}
//**********************************
//AD conversion initialization subroutine //
//*********************************
Voidad_initial()//
{
ADCON0=0B01001001;//fosc/8RA1/AN1ADON=1
ADCON1=0B00000010;//AN0-AN4=AVREF=VDD
ADIE=1;//
PEIE=1;//
}
//**********************************
//Key processing subroutine //
//**********************************
Voidkeywork()//
{
If((PORTB&0xFF)!=0xFF)//If P1.2--P1.4 is not all 1, there may be a key press
{
Delay_10ms();//delay debounce
If((PORTB&0xFF)!=0xFF)//Reread P1.2-P1.4 bit, if it is still not all 1, there is a key press
{
If((PORTB&0xF0)!=0xF0)//Reread P1.2-P1.4 bit, if it is still not all 1, there is a key press
{
//-------------------------------------------
If(KEY_SET==0)//Press the SET button, such as exiting in the SET state, otherwise enter
{
RC4=!RC4;
Keywait();
Return;
}
Elseif (KEY_DOWN==0) / / press the DOWN button
{
RC3=!RC3;
Keywait();
Return;
}
Elseif (KEY_UP==0) / / press the UP button
{
RC2=!RC2;
Keywait();
Return;
}
}
}
}
}
//--------------------------------------
//--------------------------------------
//Tmr0 interrupt program
Voidinterruptclkint(void)
{
TMR0=0x13;//
T0IF=0;//
CLRWDT();//
Sreg=sreg+1;//
If(sreg==40)//
{//
Sreg=0;//
Buf[3]++;
If(buf[3]>9)
{buf[3]=0;
Buf[2]++;
If(buf[2]>9)
{buf[2]=0;
Buf[1]++;
If(buf[1]>9)
{buf[1]=0;
Buf[0]++;
If(buf[0]>9)buf[0]=0;
}
}
}
}
}
/*******************************Main function ****************** **************/
Main()//main function
{
OPTION=0B00000000;//
STATUS=0X00;//
ADCON1=0B00000000;//
INTCON=0X00;//
PIE1=0B00000000;//
PIR1=0X00;//
T1CON=0B00000000;//
T0CS=0;//
PSA=1;//
T0IF=0;//
T0IE=1;//
TRISB=0XFF;//
TRISC=0X00;//
PORTB=0XFF;//
PORTC=0X00;//
Buf_initial();//
While(1)//
{
Keywork();//
}
}
For the 33kV Oil Immersed Power Transformer, we can produce capacity upto 50MVA. We use the best quality of raw material and advance design software to provide low noise, low losses, low partial discharge and high short-circuit impedance for power transformer.
Our power transformer are widely used in national grid, city grid, rural grid, power plant, industrial and mining enterprise, and petrochemical industry.
Conventer Transformer,33Kv Power Transformer,33Kv Power Transformer With Octc,Power Transformer With Octc
Hangzhou Qiantang River Electric Group Co., Ltd.(QRE) , https://www.qretransformer.com