1 | /*******************************************************************************
|
2 | MCU: PIC18F66K80
|
3 | Oscillator: HS, 18.0000 MHz
|
4 | ******************************************************************************/
|
5 | #define IP_adress PORTF
|
6 |
|
7 |
|
8 | char lcd_line1[20], lcd_line2[20], lcd_line3[20], lcd_line4[20] ;
|
9 | unsigned char IDmodule=0;
|
10 |
|
11 |
|
12 | // Lcd module connections
|
13 | sbit LCD_RS at LATD4_bit;
|
14 | sbit LCD_EN at LATD6_bit;
|
15 | sbit LCD_D4 at LATD0_bit;
|
16 | sbit LCD_D5 at LATD1_bit;
|
17 | sbit LCD_D6 at LATD2_bit;
|
18 | sbit LCD_D7 at LATD3_bit;
|
19 |
|
20 | sbit LCD_RS_Direction at TRISD4_bit;
|
21 | sbit LCD_EN_Direction at TRISD6_bit;
|
22 | sbit LCD_D4_Direction at TRISD0_bit;
|
23 | sbit LCD_D5_Direction at TRISD1_bit;
|
24 | sbit LCD_D6_Direction at TRISD2_bit;
|
25 | sbit LCD_D7_Direction at TRISD3_bit;
|
26 | // End Lcd module connections
|
27 |
|
28 | //------------------------------------------------------------------------------
|
29 | // Startup Configuration
|
30 | //------------------------------------------------------------------------------
|
31 | void configure_mcu(void)
|
32 | {
|
33 |
|
34 |
|
35 | ANCON0 = 0x00;
|
36 | ANCON1 = 0x00; // No analog inputs
|
37 |
|
38 | TRISA = 0x00;
|
39 | LATA = 0x00;
|
40 |
|
41 | TRISC = 0; // set PORTC as output
|
42 | PORTC = 0; // clear PORTC
|
43 |
|
44 | TRISD = 0;
|
45 | TRISE = 16; // RE4 as input, RE5 as output
|
46 | WPUB = 0x00; // Disable all PORTB pull-up resistors
|
47 | TRISF = 0xFF; // set PORTF as input
|
48 | }
|
49 |
|
50 | void main() {
|
51 | configure_mcu();
|
52 | Lcd_Init(); // Initialize Lcd
|
53 | IDmodule = 1;
|
54 |
|
55 | Lcd_Cmd(_LCD_CLEAR); // Clear display
|
56 | Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
|
57 | Delay_ms(100);
|
58 |
|
59 | sprintf(lcd_line1, "Modul ID = %d", IDmodule);
|
60 | Lcd_Out(1,1, lcd_line1);
|
61 | Delay_ms(100);
|
62 |
|
63 | sprintf(lcd_line2, "Length = %d", IDmodule);
|
64 | Lcd_Out(2,1, lcd_line2); // Write text
|
65 | Delay_ms(20);
|
66 |
|
67 | sprintf(lcd_line3, "Rx_ID = %d", IDmodule);
|
68 | Lcd_Out(3,1, lcd_line3); // Write text
|
69 |
|
70 | sprintf(lcd_line4, "Payload = %d", IDmodule);
|
71 | Lcd_Out(4,1, lcd_line4); // Write text
|
72 | }
|