1 |
#include "main.h" |
1 |
#include "main.h" |
2 |
|
2 |
|
3 |
#define LCD_ENABLE_PIN PIN_E0 //// |
3 |
#define LCD_ENABLE_PIN PIN_E0 //// |
4 |
#define LCD_RS_PIN PIN_E1 //// |
4 |
#define LCD_RS_PIN PIN_E1 //// |
5 |
#define LCD_RW_PIN PIN_E2 //// |
5 |
#define LCD_RW_PIN PIN_E2 //// |
6 |
#define LCD_DATA4 PIN_D4 //// |
6 |
#define LCD_DATA4 PIN_D4 //// |
7 |
#define LCD_DATA5 PIN_D5 //// |
7 |
#define LCD_DATA5 PIN_D5 //// |
8 |
#define LCD_DATA6 PIN_D6 //// |
8 |
#define LCD_DATA6 PIN_D6 //// |
9 |
#define LCD_DATA7 PIN_D7 |
9 |
#define LCD_DATA7 PIN_D7 |
10 |
#include <lcd.c> |
10 |
#include <lcd.c> |
11 |
|
11 |
|
- |
|
12 |
#define BEEPER PIN_B5 |
- |
|
13 |
|
- |
|
14 |
int beep() |
- |
|
15 |
{ |
- |
|
16 |
unsigned int i; |
- |
|
17 |
|
- |
|
18 |
i=0; |
- |
|
19 |
for(i=0;i<100;i++) |
- |
|
20 |
{ |
- |
|
21 |
output_low(BEEPER); |
- |
|
22 |
delay_ms(1); |
- |
|
23 |
output_high(BEEPER); |
- |
|
24 |
delay_ms(1); |
- |
|
25 |
} |
- |
|
26 |
} |
- |
|
27 |
|
- |
|
28 |
|
12 |
void main() |
29 |
void main() |
13 |
{ |
30 |
{ |
14 |
int16 i=0; |
31 |
int16 i=0; |
15 |
|
32 |
|
16 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
33 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
17 |
setup_adc(ADC_CLOCK_DIV_2); |
34 |
setup_adc(ADC_CLOCK_DIV_2); |
18 |
setup_spi(SPI_SS_DISABLED); |
35 |
setup_spi(SPI_SS_DISABLED); |
19 |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
36 |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
20 |
setup_timer_1(T1_DISABLED); |
37 |
setup_timer_1(T1_DISABLED); |
21 |
setup_timer_2(T2_DISABLED,0,1); |
38 |
setup_timer_2(T2_DISABLED,0,1); |
22 |
setup_ccp1(CCP_OFF); |
39 |
setup_ccp1(CCP_OFF); |
23 |
setup_comparator(NC_NC_NC_NC); // This device COMP currently not supported by the PICWizard |
40 |
setup_comparator(NC_NC_NC_NC); // This device COMP currently not supported by the PICWizard |
24 |
setup_oscillator(OSC_8MHZ); |
41 |
setup_oscillator(OSC_8MHZ); |
25 |
|
42 |
|
26 |
lcd_init(); |
43 |
lcd_init(); |
27 |
lcd_putc("(c) Kaklik 2013"); |
44 |
lcd_putc("(c) Kaklik 2013"); |
28 |
lcd_gotoxy(3,2); |
45 |
lcd_gotoxy(3,2); |
29 |
lcd_putc("www.mlab.cz"); |
46 |
lcd_putc("www.mlab.cz"); |
30 |
Delay_ms(2000); |
47 |
Delay_ms(2000); |
31 |
lcd_init(); |
48 |
lcd_init(); |
32 |
|
49 |
|
33 |
while (TRUE) |
50 |
while (TRUE) |
34 |
{ |
51 |
{ |
35 |
lcd_gotoxy(1,1); |
52 |
lcd_gotoxy(1,1); |
36 |
|
53 |
|
37 |
printf(lcd_putc,"LCD test"); |
54 |
printf(lcd_putc,"LCD test"); |
38 |
lcd_gotoxy(1,2); |
55 |
lcd_gotoxy(1,2); |
39 |
printf(lcd_putc,"%c %x ",i,i); |
56 |
printf(lcd_putc,"%c %x ",i,i); |
40 |
i++; |
57 |
i++; |
41 |
|
58 |
beep(); |
42 |
Delay_ms(500); |
59 |
Delay_ms(500); |
43 |
} |
60 |
} |
44 |
|
61 |
|
45 |
} |
62 |
} |