xiaoxiaocheng_plc/users/main.c

84 lines
2.7 KiB
C
Raw Normal View History

2018-11-13 22:25:34 +08:00
/********************************************************/
// CPU<50><55>Ҫ<EFBFBD><D2AA>STM32F103--RAM<41>ڴ治С<E6B2BB><D0A1>48K Flash<73>ڴ治С<E6B2BB><D0A1>256K
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>STM32F103RDT6<54><36>VET6<54><36><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>
// <20><EFBFBD><E0BCAD><EFBFBD>ڣ<EFBFBD>20160917
// editor by СС<D0A1><D0A1>
// <20><><EFBFBD>꣺shop182385147.taobao.com
/********************************************************
20151023<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><EFBFBD>β<EFBFBD>RUN<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
20151125<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>س<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>о<EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
20151204<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PLCΪSTOPʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>T<EFBFBD><EFBFBD>D<EFBFBD><EFBFBD>C<EFBFBD>Լ<EFBFBD>M<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>FX2N<EFBFBD><EFBFBD>PLCһ<EFBFBD><EFBFBD>
20160423<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD>ܺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD>
20160510<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Բ<EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ż<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܹ<EFBFBD>
20160609<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>485 modbus<EFBFBD><EFBFBD>rtcͨ<EFBFBD><EFBFBD>Э<EFBFBD>ʹ<EFBFBD><EFBFBD>usart3
20160622<EFBFBD><EFBFBD> D8121<EFBFBD><EFBFBD>վ<EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD>Ĭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>D8130<EFBFBD><EFBFBD><EFBFBD><EFBFBD>վѡ<EFBFBD><EFBFBD> 0<EFBFBD><EFBFBD><EFBFBD><EFBFBD>վ
20160710: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>1·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Y0<EFBFBD><EFBFBD>PLSY
20160914<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>RTCʱ<EFBFBD>ӹ<EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>D8019<EFBFBD><EFBFBD><EFBFBD><EFBFBD>D8018<EFBFBD><EFBFBD><EFBFBD><EFBFBD>D8017<EFBFBD><EFBFBD><EFBFBD><EFBFBD>D8016<EFBFBD><EFBFBD>ʱD8015<EFBFBD><EFBFBD><EFBFBD><EFBFBD>D8014<EFBFBD><EFBFBD> <EFBFBD><EFBFBD>D8013
20160929<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><EFBFBD>FOR<EFBFBD><EFBFBD>ѭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>NEST 2<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
********************************************************/
#include "main.h"
#include "PLC_Dialogue.h"
u8 power_down;
u8 run_flag;
u16 Timer1[2];
extern bit_byte PLC_16BIT[12100];
extern void mosbus_485_USART3(void);
int main(void)
{
power_down=10;
PLC_IO_config(); // PLC<4C><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
RTC_Init(); // RTCʱ<43><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
data_init(); // <20><><EFBFBD><EFBFBD>D8000~D8126<32><36>ʼ<EFBFBD><CABC>
Recover_data(); // PLC<4C>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD>ݻָ<DDBB>
USART1_Configuration(); // <20><><EFBFBD>ڳ<EFBFBD>ʼ<EFBFBD><CABC>
USART3_Configuration();
PLC_Timer(); // TIMER2 <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EEB5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ADC_init(); // ADC<44><43>ʼ<EFBFBD><CABC>
NCIC_Confinguration(ENABLE); // <20><><EFBFBD><EFBFBD><EFBFBD>жϳ<D0B6><CFB3><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD>
while(1)
{
Err_Lamp_OFF;
// RST_C(); // <20><><EFBFBD>ټ<EFBFBD><D9BC><EFBFBD><EFBFBD><EFBFBD>
RTC_Get(); // ʱ<><CAB1>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
PLC_ProInstructParse(); // PLCָ<43><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mosbus_485_USART3();
if(Send_out)
TX_Process(); // <20><><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//* <09>͵<EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD> <20>ϵ籣<CFB5><E7B1A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if(!PVD) //MY PCB== !PVD
{
if(Timer1[0]==0)
Recover_data();
if(Timer1[0]<=60000)
Timer1[0]++;
}
else
{
// all_data[0x180/2]=0;
if(Timer1[0]>=100)
{
PLC_16BIT[80].bytes = 0; //<2F>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD>IO<49><4F><EFBFBD><EFBFBD>
PLC_DATA_KEEP();
NCIC_Confinguration(DISABLE); //<2F>ر<EFBFBD><D8B1>жϳ<D0B6><CFB3><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD>
Timer1[0]=0;
}
}
//*/
// if(power_down==0) //<2F>ж<EFBFBD><D0B6>Dz<EFBFBD><C7B2>Ƕϵ<C7B6>
// {
// NCIC_Confinguration(DISABLE); //<2F>ر<EFBFBD><D8B1>жϳ<D0B6><CFB3><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD>
// PLC_DATA_KEEP();
// while(1){;}
// }
}
}