#include const uchar ee_data[]={1,2,3,3,2,1}; while(1) SSPSTAT=0x80;
#define uchar unsigned char
#define uint unsigned int
#define add 0xaa
__CONFIG(0xc3e4);
__CONFIG(0xffff);
#define DS1302 RC2 //Define to turn off the DS1302 clock chip so that the RC4 RC3 IO ports can be used for AT24C02 control.
uchar read_data[6];
const uchar table[]={0x3f, 0x6, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x7, 0x7f, 0x6f};
void delay(uint x);
void init();
void disp(uchar num1,uchar num2,uchar num3,uchar num4,uchar num5,uchar num6);
void write();
void read();
void main()
{
init();
DS1302=0;// 关掉DS1302
write();
delay(100);
read();
{
disp(read_data[0],read_data[1],read_data[2],read_data[3],read_data[4],read_data[5]);
}
}
void delay(uint x)
{
uint a,b;
for(a=x;a>0;a--)
for(b=110;b>0;b--);
}
void init()
{
TRISD=0;
TRISA=0;
//TRISC=0;
TRISE0=1;
// ADCON1=0x07;
//RE0=1;
PORTD=0x3f;
PORTA=0x00;
TRISC=0x18;//用到RC3 RC4 输入 1
SSPCON=0x38;
SSPCON2=0;
SSPADD=0x09;
//PORTE=1;
}
void write()
{
uchar i;
SSPIF=0;
SEN=1;
while(!SSPIF);
SSPIF=0;
SSPBUF=0xA0;
while(!SSPIF);
SSPIF=0;
SSPBUF=add;
while(!SSPIF);
SSPIF=0;
for(i=0;i<6;i++)
{
SSPBUF=ee_data[i];
while(!SSPIF);
SSPIF=0;
}
PEN=1;
while(!SSPIF);
SSPIF=0;
}
void read()
{
uchar i;
SSPIF=0;
SEN=1;
while(!SSPIF);
SSPIF=0;
SSPBUF=0xA0;
while(!SSPIF);
SSPIF=0;
SSPBUF=add;
while(!SSPIF);
SSPIF=0;
SSPIF=0;
RSEN=1;
while(!SSPIF);
SSPIF=0;
SSPBUF=0xA1;
while(!SSPIF);
SSPIF=0;
for(i=0;i<6;i++)
{
RCEN=1;
while(!SSPIF);
read_data[i]=SSPBUF;
while(!SSPIF);
SSPIF=0;
if(i>=5)
{
ACKDT=1;
}
else
{
ACKDT=0;
}
ACKEN=1;
while(!SSPIF);
SSPIF=0;
}
PEN=1;
while(!SSPIF);
SSPIF=0;
}
void disp(uchar num1,uchar num2,uchar num3,uchar num4,uchar num5,uchar num6)
{
PORTD=table[num1];//Display the first digital tube
PORTA=0x01;//0010 0000
delay(2);
PORTD=table[num2];//Display the second digital tube
PORTA=0x02;//0001 0000
delay(2);
PORTD=table[num3];//Display the third digital tube
PORTA=0x04;//0000 1000
delay(2);
PORTD=table[num4];//Display the fourth digital tube
PORTA=0x08;//0000 0100
delay(2);
PORTD=table[num5];//Display the fifth digital tube
PORTA=0x10;//0000 0010
delay(2);
PORTD=table[num6]; //Display the sixth digital tube
PORTA=0x20; //0000 0001
delay(2);
}
Previous article:CONGFIG description of PIC microcontroller in ZC-ADK
Next article:LED single light flashing experiment of PIC microcontroller under proteus+MPLAB combination
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- Molex leverages SAP solutions to drive smart supply chain collaboration
- Pickering Launches New Future-Proof PXIe Single-Slot Controller for High-Performance Test and Measurement Applications
- Apple faces class action lawsuit from 40 million UK iCloud users, faces $27.6 billion in claims
- Apple faces class action lawsuit from 40 million UK iCloud users, faces $27.6 billion in claims
- The US asked TSMC to restrict the export of high-end chips, and the Ministry of Commerce responded
- The US asked TSMC to restrict the export of high-end chips, and the Ministry of Commerce responded
- EEWORLD University Hall----RF Analog Circuits Yang Yumei, University of Electronic Science and Technology of China
- [Brick Drinking Water Recorder] Ubuntu Environment Construction of "ESP32-S2-Kaluga-1"
- my country has built more than 910,000 5G base stations, accounting for 70% of the world. What do you think about this?
- The zigbee terminal and the router cannot communicate with each other, but the coordinator can communicate with them
- Switching Power Supply PCB Layout Technology
- [NXP Rapid IoT Review] + Unfortunately, connection failed
- How to disable ADC to reduce power consumption in ESP32
- After using MAX735 to convert +5V to -5V, the dual-power op amp is powered and -5V is pulled down to 0V
- E104-BT02 Bluetooth wireless transmission module IoT chip intelligent control, collection
- TI CC3200 WIFI Training Development Kit (OURS-SDK-WFB Debug 2 - Familiarity with IAR for ARM.