📄 main.lst
字号:
1: /* Gestione di un Display LCD HD**** con la DemoBoard V1
2: Le funzioni in lcd.c sono state adattate alla DemoBoard.
3: Author : Antonio Bruno 0803
4:
5: PIN I/O PIC DEMOBOARD V1
6:
7: RB0 pulsante nero
8: RB1 pulsante blu
9: RB2
10: RB3 EN display
11: RB4 DB4 display
12: RB5 DB5 display
13: RB6 DB6 display
14: RB7 DB7 display
15:
16: RA0 SCL pin I2C
17: RA1 SDA pin I2C
18: RA2 TX seriale o libero (vedi jumper)
19: RA3 RX seriale o libero (vedi jumper)
20: RA4 RS display
21: */
22: #define XTAL_FREQ 4MHZ /* Crystal frequency in MHz */
23:
24: #include <pic.h>
25: #include "lcd.h"
26: #include "delay.h"
27: #include "stdio.h"
28: #include "ds1307.h"
29: #include "convers.h"
30:
31: __CONFIG (XT&WDTDIS);
32:
33: #define PORTBIT(adr,bit) ((unsigned)(&adr)*8+(bit))
34:
35: static bit BUTTON @ PORTBIT(PORTB,0);
36: static bit SDA @ PORTBIT(PORTA,1);
37:
38: main()
39: {
40: unsigned char str[5];
41: int i;
42: TRISB = 3; /* portb.0 e portb.1 = ingressi */
43: TRISA = 0b00000010; /* porta tutte uscite */
44: PORTB=0;
45: PORTA=0;
46:
47: while(1)
48: {
49:
50: lcd_init();
51: TRISA=0b00000010;
52:
53: DelayMs(250);
54: rtc_write(0,0); //reg secondi + start clock
55: rtc_write(1,dec_bcd(25)); //reg minuti
56: rtc_write(2,dec_bcd(19)); //reg ore
57: rtc_write(4,dec_bcd(11)); //reg day
58: rtc_write(5,dec_bcd(11)); //reg month
59: rtc_write(6,dec_bcd(3)); //reg year
60:
61: while(1)
62: {
63: if(BUTTON)
64: rtc_write(1,rtc_read(1)+1);
65:
66: lcd_clear();
67:
68: i=rtc_read(2); //ore
69: i=bcd_dec(i);
70: itoa((char)i,str);
71: lcd_puts(str);
72: lcd_puts(":");
73:
74: i=rtc_read(1); //minuti
75: i=bcd_dec(i);
76: itoa((char)i,str);
77: lcd_puts(str);
78: lcd_puts(":");
79:
80: i=rtc_read(0); //secondi
81: i=bcd_dec(i);
82: itoa((char)i,str);
83: lcd_puts(str);
84:
85: lcd_goto(0x40);
86: i=rtc_read(4); //date day
87: i=bcd_dec(i);
88: itoa((char)i,str);
89: lcd_puts(str);
90:
91: lcd_puts("/");
92: i=rtc_read(5); //date month
93: i=bcd_dec(i);
94: itoa((char)i,str);
95: lcd_puts(str);
96:
97: lcd_puts("/");
98: i=rtc_read(6); //date year
99: i=bcd_dec(i);
100: itoa((char)i,str);
101: lcd_puts(str);
102:
103: DelayMs(250);
104:
105: }
106:
107: }
108: }
109:
110:
111:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -