接的别人的程序,通讯不上!
void main(void)
{
static uchar fx,zt,gl,zc,gb,gbn,ON3,ON4,OFF4;
static uint i;
asm("sim");
gpio_init();
adc_init();
uart1_init();
eep_init();
asm("rim");
wdg_start();
timer2_init();
t05=0;
while(!t05){wdr();}
t05=0;
while(!t05){wdr();}
t05=0;
comp=0;
comc=0;
zt=0x17;
gl=40;
zc=0;
gbn=0;
………………
void gpio_init(void)
{
//pc3, pc4 ,pp out
//PC_DDR = 1<<3|1<<4;
//PC_CR1 = 1<<3|1<<4;
PC_DDR=0xff;
PC_CR1=0xff;
//pc3, pc4, pp out
//PD_DDR = 1<<4|1<<5;
//PD_CR1 = 1<<4|1<<5;
//2,3,6=input
PD_DDR=0xb3;
PD_CR1=0xb3;
}
//ADC
void adc_init(void)
{
ADC_CR1_ADON = 1;
ADC_CSR_CH = 3;
ADC_CR2_ALIGN = 0;
ADC_CR1_SPSEL = 2;
ADC_TDRL = (1 << 3) | (1 << 4); //ch3 ,ch 4
}
//串口
void uart1_init(void)
{
UART1_CR1=0x10;
UART1_CR2=0x00;
UART1_CR3=0x00;
UART1_BRR2 = 0x00;
UART1_BRR1 = 0x60;
UART1_CR2_TEN = 1;
UART1_CR2_REN = 1;
UART1_CR2_RIEN = 1;
}
//EEPROM
void eep_init(void)
{
FLASH_CR1 = 0x00;
FLASH_CR2 = 0x00;
FLASH_NCR2 = 0xff;
FLASH_DUKR = MASS_KEY1;
FLASH_DUKR = MASS_KEY2;
while(!FLASH_IAPSR_DUL);
}
void timer2_init(void)
{
TIM2_CR1 = 0;
TIM2_PSCR_PSC = 9;
TIM2_ARRH = 0x07;
TIM2_ARRL = 0x08;
TIM2_IER = 0x01;
TIM2_CR1 = 0x01;
}
|