📄 main.c
字号:
#include "F:\sunzhonghai\ALLWAY\code887\code887+v2\main.h"
// #include <math.h>
// #include <string.h>
int16 cme500ms = 0;
unsigned char ctime0_count = 0;
#define LF_High set_pwm1_duty(7);
#define LF_Low set_pwm1_duty(20);
void Lf_putout(unsigned char HL,unsigned char times);
void Lf_Send(int16 Lf_data);
#ZERO_RAM
#int_RTCC
void RTCC_isr(void) //0.5ms
{
ctime0_count++;
if(ctime0_count>250)
{
ctime0_count = 0;
}
cme500ms++;
if(cme500ms>500)
{
cme500ms = 0;
output_high(PIN_A4);
}
else if(cme500ms>250)
{
output_low(PIN_A4);
}
}
#int_TBE
void TBE_isr(void)
{
}
#int_RDA
void RDA_isr(void)
{
}
void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_4);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DIV_BY_1,15,1);
//setup_timer_2(T2_DIV_BY_1, 127, 1);
setup_ccp1(CCP_PWM);//,CCP_PWM_HALF_BRIDGE);
set_pwm1_duty(7);
setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
enable_interrupts(INT_RTCC);
// enable_interrupts(INT_TBE);
// enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
setup_oscillator(OSC_8MHZ);
// TODO: USER CODE!!
// TRISA = 0;
output_low(PIN_A4);
output_high(PIN_A4);
output_low(PIN_A4);
output_high(PIN_A4);
while(1)
{
restart_wdt();
if(ctime0_count>200)
{
Lf_Send(0xf05a);
}
}
}
void Lf_Send(int16 Lf_data)
{
int16 wlf_data,i;
wlf_data = Lf_data;
Lf_putout(1,12); //TSTAB(AFE 稳定) = TAGC+TPAGC 6ms
Lf_putout(0,1); //TGAP(间隔脉冲) 0.5ms
Lf_putout(1,9); //t ≥ TOEH(验收滤波器高电平时间) 4.5ms>4ms
Lf_putout(0,9); //t ≥ TOEL(验收滤波器低电平时间) 4.5ms>4ms
//TOEH+TOEL≤TOET 4.5ms+4.5ms<10ms
for(i=0;i<16;i++)
{
if(wlf_data&(0x8000>>i))
{
Lf_putout(1,1); //125k*0.5ms
}
else
{
Lf_putout(0,1); //0k*0.5ms
}
}
LF_Low;
}
void Lf_putout(unsigned char HL,unsigned char times) //times*0.5ms
{
unsigned char cHigh_Low;
unsigned char ctime;
cHigh_Low = HL;
ctime = times;
if(cHigh_Low)
{
LF_High;
}
else
{
LF_Low;
}
set_timer0(0);
ctime0_count = 0;
while(ctime0_count<times);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -