📄 rec_f.c
字号:
#include <Absacc.h>
#include <reg51.h>
#include <math.h>
#include <ADC0809.h>
#include <DISP7289.h>
#include <SJA1000.h>
main()
{ uint v_value,a,b,c;
SJA_INI();
while(1)
{
v_value=REC();
v_value=v_value*100/255;
a=v_value/100;
b=v_value%100/10;
c=v_value%100%10;
LED_DELAY_DISP();
LED_DISP(3,a);
LED_DISP(2,b);
LED_DISP(1,c);
LED_DISP(8,0x0c);
}
}
void LED_SEND(unsigned char Send_Value)
{
unsigned char BIT_CNT;
BIT_CNT=0x08;
LED_DELAY_LONG();
while( BIT_CNT!=0)
{
DIO=((Send_Value>>(BIT_CNT-1))&0x01);
CLK=1;
LED_DELAY_SHORT();
CLK=0;
LED_DELAY_SHORT();
BIT_CNT--;
}
}
void LED_DISP(unsigned char Led_Number,unsigned char Send_Value)
{
unsigned char Disp_BUF;
if(Led_Number==1)
Led_Number=FIRST_LED;
if(Led_Number==2)
Led_Number=SECOND_LED;
if(Led_Number==3)
Led_Number=THIRD_LED;
if(Led_Number==4)
Led_Number=FOURTH_LED;
if(Led_Number==5)
Led_Number=FIFTH_LED;
if(Led_Number==6)
Led_Number=SIXTH_LED;
if(Led_Number==7)
Led_Number=SEVENTH_LED;
if(Led_Number==8)
Led_Number=EIGHTH_LED;
CS=0;
LED_DELAY_SHORT();
Disp_BUF=Led_Number;
LED_SEND(Disp_BUF);
LED_DELAY_SHORT();
LED_DELAY_LONG();
Disp_BUF=Send_Value;
LED_SEND(Disp_BUF);
CS=1;
LED_DELAY_LONG();
}
void LED_DELAY_SHORT(void) //短延时
{
unsigned char j;
for(j=0;j<20;j++);//for(j=0;j<5*10;j++);
}
void LED_DELAY_LONG(void) //长延时
{
unsigned char j;
for(j=0;j<160;j++)//for(j=0;j<25*10;j++)
{;}
}
void LED_TEST(void)
{
CS=0;
LED_DELAY_SHORT();
SEND_BUF=0XBF;
LED_SEND(SEND_BUF);
LED_DELAY_SHORT();
LED_DELAY_LONG();
CS=1;
LED_DELAY_LONG();
}
void LED_RESET(void)
{
CS=0;
LED_DELAY_SHORT();
SEND_BUF=0XC4;
LED_SEND(SEND_BUF);
LED_DELAY_SHORT();
LED_DELAY_LONG();
CS=1;
LED_DELAY_LONG();
}
void LED_DELAY_DISP(void) //延时
{
unsigned int j;
for(j=0;j<25000;j++);//for(j=0;j<25*10;j++)
}
uint REC(void)
{
uint q,v_value;
v_value=RXB5;
CMR=0x04;
return v_value;
}
void SJA_INI(void)
{
MODE=0x09;
CDR=0x88;
IER=0x0E;
ACR0=0xFF;
ACR1=0xFF;
ACR2=0xFF;
ACR3=0xFF;
AMR0=0xFF;
AMR1=0xFF;
AMR2=0xFF;
AMR3=0xFF;
BTR0=0x03;
BTR1=0xFF;
OCR=0xAA;
RBSA=0x00;
TXERR=0x00;
ECC=0x00;
MODE=0x08;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -