📄 main.c
字号:
#include "p18f4620.h"
#include "Console.h"
#include "powerManager.h"
#include "initial.h"
#include "S6700.h"
#include "timer.h"
uchar cTemp;
uchar timer_flag; //flag of timer when read data from smartlabel
uchar receive_flag=0;
uchar id_add = 0;
uchar me = 0;
uchar converse_char;
uint converse_int;
uchar Data_buf[32]; //Data_buf is used to store data both from host(PC) and from Smartlabel
uchar Comm_buf[16];
uchar flag = 0;
uchar count = 0;
uchar coutint = 0;
//void timer_isr (void);
#pragma config WDT = OFF
//#pragma config OSC = INTIO7 //内部时钟选择
void main ()
{
uchar Try=0;
//////////////////////////////////////////////////////////
////////////////88888888888888888//////////////
OutputIO('D',0x01);
OutputIO('D',0x02);
//初始化串口
ConsoleInit();
//初始化RFID,
InitRFID();
PORTD &= ~RLED;
////////////////88888888888888888//////////////
//OSCCON |= 0x70; //选择8M
//OSCTUNE |= 0x40; //使能PLLEN
//PORTDbits.RD1 = 1;
while(1)
{
PORTDbits.RD0 = 1;
count++;
ConsolePut(0xFF);
do//read the password in block 01 into Data_buf[3]-Data_buf[6]
{
Data_buf[0] = Read_block(0x01);
Try++;
}while ((Data_buf[0] != 8)&&(Try < 8));
ConsolePut(count);
ConsolePut(Try);
Try = 0;
if((Data_buf[0] == 0x08) && timer_flag)
{
PORTDbits.RD0 ^= 1;
}
ConsolePut(Data_buf[0]);
ConsolePut(Data_buf[3]);
ConsolePut(Data_buf[4]);
ConsolePut(Data_buf[5]);
ConsolePut(Data_buf[6]);
ConsolePut(coutint);
}
}
/////////////////////////////////////////////////////////////
////////Timer0中断处理程序
////////////////////////////////////////////////////////////
#pragma code low_vector=0x18
#pragma interruptlow timer_isr
void low_interrupt (void)
{
_asm GOTO timer_isr _endasm
}
#pragma code
void
timer_isr (void)
{
INTCONbits.TMR0IF = 0; //清空终端标志
INTCONbits.TMR0IE = 0; //关闭Timer0中断
timer_flag = 0;
coutint++;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -