1 |
/* |
1 |
/* |
2 |
#include <18F4550.h> |
2 |
#include <18F4550.h> |
3 |
|
3 |
|
4 |
#FUSES NOWDT //No Watch Dog Timer |
4 |
#FUSES NOWDT //No Watch Dog Timer |
5 |
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale |
5 |
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale |
6 |
#FUSES HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD) |
6 |
#FUSES HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD) |
7 |
#FUSES NOPROTECT //Code not protected from reading |
7 |
#FUSES NOPROTECT //Code not protected from reading |
8 |
#FUSES NOBROWNOUT //No brownout reset |
8 |
#FUSES NOBROWNOUT //No brownout reset |
9 |
#FUSES BORV20 //Brownout reset at 2.0V |
9 |
#FUSES BORV20 //Brownout reset at 2.0V |
10 |
#FUSES NOPUT //No Power Up Timer |
10 |
#FUSES NOPUT //No Power Up Timer |
11 |
#FUSES NOCPD //No EE protection |
11 |
#FUSES NOCPD //No EE protection |
12 |
#FUSES STVREN //Stack full/underflow will cause reset |
12 |
#FUSES STVREN //Stack full/underflow will cause reset |
13 |
#FUSES NODEBUG //No Debug mode for ICD |
13 |
#FUSES NODEBUG //No Debug mode for ICD |
14 |
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O |
14 |
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O |
15 |
#FUSES NOWRT //Program memory not write protected |
15 |
#FUSES NOWRT //Program memory not write protected |
16 |
#FUSES NOWRTD //Data EEPROM not write protected |
16 |
#FUSES NOWRTD //Data EEPROM not write protected |
17 |
#FUSES IESO //Internal External Switch Over mode enabled |
17 |
#FUSES IESO //Internal External Switch Over mode enabled |
18 |
#FUSES FCMEN //Fail-safe clock monitor enabled |
18 |
#FUSES FCMEN //Fail-safe clock monitor enabled |
19 |
#FUSES PBADEN //PORTB pins are configured as analog input channels on RESET |
19 |
#FUSES PBADEN //PORTB pins are configured as analog input channels on RESET |
20 |
#FUSES NOWRTC //configuration not registers write protected |
20 |
#FUSES NOWRTC //configuration not registers write protected |
21 |
#FUSES NOWRTB //Boot block not write protected |
21 |
#FUSES NOWRTB //Boot block not write protected |
22 |
#FUSES NOEBTR //Memory not protected from table reads |
22 |
#FUSES NOEBTR //Memory not protected from table reads |
23 |
#FUSES NOEBTRB //Boot block not protected from table reads |
23 |
#FUSES NOEBTRB //Boot block not protected from table reads |
24 |
#FUSES NOCPB //No Boot Block code protection |
24 |
#FUSES NOCPB //No Boot Block code protection |
25 |
#FUSES MCLR //Master Clear pin enabled |
25 |
#FUSES MCLR //Master Clear pin enabled |
26 |
#FUSES LPT1OSC //Timer1 configured for low-power operation |
26 |
#FUSES LPT1OSC //Timer1 configured for low-power operation |
27 |
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode) |
27 |
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode) |
28 |
#FUSES PLL12 //Divide By 12(48MHz oscillator input) |
28 |
#FUSES PLL12 //Divide By 12(48MHz oscillator input) |
29 |
#FUSES CPUDIV1 //System Clock by 1 |
29 |
#FUSES CPUDIV1 //System Clock by 1 |
30 |
#FUSES USBDIV //USB clock source comes from PLL divide by 2 |
30 |
#FUSES USBDIV //USB clock source comes from PLL divide by 2 |
31 |
#FUSES VREGEN //USB voltage regulator enabled |
31 |
#FUSES VREGEN //USB voltage regulator enabled |
32 |
#FUSES ICPRT //ICPRT enabled |
32 |
#FUSES ICPRT //ICPRT enabled |
33 |
*/ |
33 |
*/ |
34 |
|
34 |
|
35 |
#include <16F887.h> |
35 |
#include <16F887.h> |
36 |
#device adc=8 |
36 |
#device adc=8 |
37 |
|
37 |
|
38 |
#FUSES NOWDT //No Watch Dog Timer |
38 |
#FUSES NOWDT //No Watch Dog Timer |
39 |
#FUSES HS //Internal RC Osc |
39 |
#FUSES HS //External crystal oscillator |
40 |
#FUSES NOPUT //No Power Up Timer |
40 |
#FUSES NOPUT //No Power Up Timer |
41 |
#FUSES MCLR //Master Clear pin enabled |
41 |
#FUSES MCLR //Master Clear pin enabled |
42 |
#FUSES NOPROTECT //Code not protected from reading |
42 |
#FUSES NOPROTECT //Code not protected from reading |
43 |
#FUSES NOCPD //No EE protection |
43 |
#FUSES NOCPD //No EE protection |
44 |
#FUSES NOBROWNOUT //No brownout reset |
44 |
#FUSES NOBROWNOUT //No brownout reset |
45 |
#FUSES IESO //Internal External Switch Over mode enabled |
45 |
#FUSES IESO //Internal External Switch Over mode enabled |
46 |
#FUSES FCMEN //Fail-safe clock monitor enabled |
46 |
#FUSES FCMEN //Fail-safe clock monitor enabled |
47 |
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O |
47 |
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O |
48 |
#FUSES NODEBUG //No Debug mode for ICD |
48 |
#FUSES NODEBUG //No Debug mode for ICD |
49 |
#FUSES NOWRT //Program memory not write protected |
49 |
#FUSES NOWRT //Program memory not write protected |
50 |
#FUSES BORV40 //Brownout reset at 4.0V |
50 |
#FUSES BORV40 //Brownout reset at 4.0V |
51 |
|
51 |
|
52 |
|
52 |
|
53 |
|
53 |
|
54 |
#use delay(clock=20000000) |
54 |
#use delay(clock=20000000) |
55 |
#use rs232(baud=9600,parity=N,xmit=PIN_B7,rcv=PIN_B6,bits=8) |
55 |
#use rs232(baud=9600,parity=N,xmit=PIN_B7,rcv=PIN_B6,bits=8) |
56 |
|
56 |
|
57 |
#define TDC_ENABLE PIN_B3 //enable pin for SPI communication with TDC |
57 |
#define TDC_ENABLE PIN_B3 //enable pin for SPI communication with TDC |
58 |
#use spi(DI=PIN_B1, DO=PIN_B0, CLK=PIN_B2, stream=TDC_stream, bits=32,baud=9600) // uses software SPI |
58 |
#use spi(DI=PIN_B1, DO=PIN_B0, CLK=PIN_B2, stream=TDC_stream, bits=32,baud=9600) // uses software SPI |
59 |
|
59 |
|
60 |
|
60 |
|
61 |
|
61 |
|