Netcruzer Library API  V2.03
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups Pages
nz_din24i-r1.h
Go to the documentation of this file.
1 
34 #ifndef DIN24I_R1_H
35 #define DIN24I_R1_H
36 
37 
42 #if defined(THIS_IS_MAIN_FILE)
43  #if defined(__PIC24FJ256GB110__)
44 
45  #if !defined(CONFIGURATION_FUSES_SET)
46  #define CONFIGURATION_FUSES_SET
47 
48  //Are not defined in p24FJ128GB106
49  #define DEBUG_ON 0x77FF
50  #define DEBUG_OFF 0x7FFF
51 
52  // - JTAG Port Disabled (JTAGEN_OFF)
53  // - General Segment Code Protect = Code protection is enabled (GCP_OFF)
54  // - General Segment Write Protect Disabled (GWRP_OFF)
55  // - Emulator functions are shared with PGEC2/PGED2 (ICS_PGx2)
56  // - Watchdog Timer Disabled (FWDTEN_OFF)
57  // - WDT Prescaler = 32 (FWPSA_PR32)
58  // - Watchdog Timer Postscaler = 1:32,768 (WDTPS_PS32768)
59  _CONFIG1(JTAGEN_OFF & GCP_OFF & GWRP_OFF & ICS_PGx2 & FWDTEN_OFF)
60 
61  // - Two Speed Start-up = off (IESO_OFF)
62  // - 96MHz PLL Prescaler = No Divide, for 4MHz input (PLLDIV_NODIV)
63  // - Oscillator Selection = Primary oscillator (XT, HS, EC) w/ PLL (FNOSC_PRIPLL)
64  // - Clock switching and clock monitor = Both disabled (FCKSM_CSDCMD)
65  // - OSCO/RC15 function = RC15 (OSCIOFNC_ON)
66  // - RP Register Protection = Unlimited Writes To RP Registers (IOL1WAY_OFF)
67  // - Disable Internal USB Voltage Regulator = Disabled (DISUVREG_OFF)
68  // - Oscillator Selection = External Clock (POSCMOD_EC)
69  _CONFIG2(IESO_OFF & PLLDIV_NODIV & FNOSC_PRIPLL & FCKSM_CSDCMD & OSCIOFNC_ON & IOL1WAY_OFF & DISUVREG_OFF & POSCMOD_EC)
70 
71  // - Last page(at the top of program memory) and Flash configuration words are not protected (WPCFG_WPCFGDIS)
72  // - Segment Write Protection = Segmented code protection disabled (WPDIS_WPDIS)
73  _CONFIG3(WPCFG_WPCFGDIS & WPDIS_WPDIS) //Disable erase/write protect of all memory regions.
74  #endif
75  #else
76  #error "Not configured for valid CPU"
77  #endif
78 #endif // Prevent more than one set of config fuse definitions
79 
80 //System clock = Fosc. Instruction clock = Fcy = Fosc/2 (in datasheet)
81 #if !defined(CLOCK_FREQ)
82  #define CLOCK_FREQ (32000000ul)
83  #define GetSystemClock() (32000000ul) // Hz
84  #define GetInstructionClock() (GetSystemClock()/2)
85  #define GetPeripheralClock() GetInstructionClock()
86 #endif
87 
88 
89 
90 // *********************************************************************
91 // ----------- Daughter Board Connector Defines for SBC66ECL ------------
92 // *********************************************************************
93 
94 
95 
96 // *********************************************************************
97 // --------------------------- Other IO Defines ------------------------
98 // *********************************************************************
99 #define PIN_SYSLED _RB6
100 #define LAT_SYSLED _LATB6
101 #define DIR_SYSLED _TRISB6
102 #define PULLUP_SYSLED _CN24PUE
103 #define PULLDOWN_SYSLED _CN24PDE
104 
105 
106 
107 // *********************************************************************
108 // ---------------------------- Analog Defines -------------------------
109 // *********************************************************************
110 #define ADC_REF_MV 2500 //ADC External Reference in MV
111 
112 //PIC24FJ256GB110 has 14 ADC channels
113 //AN0-AN5 (B0-B5), AN8-AN15 (B8-B15)
114 #define ADC_MAX_CHAN_BRD 14
115 //The channel mask indicates what AN channels can be used for ADC inputs
116 #define ADC_CHANNEL_MASK_LOW_BRD 0b1100111100111111 //AN0-AN5, AN8-AN11, AN14-AN15
117 #define ADC_CHANNEL_MASK_HIGH_BRD 0 //Only has 16 ADC channels
118 
119 //PIC24FJ256GB210 has 24 ADC channels, can use following ones
120 //AN0-AN5 (B0-B5), AN8-AN15 (B8-B15), AN16 (C4), AN19 (G8), AN20 (G9), AN21 (E9), AN22 (A6)
121 //#define ADC_MAX_CHAN_BRD 19
122 //The channel mask indicates what AN channels can be used for ADC inputs
123 //#define ADC_CHANNEL_MASK_LOW_BRD 0b1111111100111111 //AN0-AN5, AN8-AN15
124 //#define ADC_CHANNEL_MASK_HIGH_BRD 0b0000000001111001 //AN16, AN19, AN20, AN21, AN22
125 
126 //Index for selected analog input in adcFilter[] and adcValue[] arrays. Some analog inputs do not have space assigned for them
127 //TODO - Replace with port names! For example ADC_CH_A0 in stead of ADC_CH_AN0
128 #define ADC_CH_AN0 0
129 #define ADC_CH_AN1 1
130 #define ADC_CH_AN2 2
131 #define ADC_CH_AN3 3
132 #define ADC_CH_AN4 4
133 #define ADC_CH_AN5 5
134 #define ADC_CH_AN8 6
135 #define ADC_CH_AN9 7
136 #define ADC_CH_AN10 8
137 #define ADC_CH_AN11 9
138 #define ADC_CH_AN12 10
139 #define ADC_CH_AN13 11
140 #define ADC_CH_AN14 12
141 #define ADC_CH_AN15 13
142 #define ADC_CH_AN16 14
143 #define ADC_CH_AN19 15
144 #define ADC_CH_AN20 16
145 #define ADC_CH_AN21 17
146 #define ADC_CH_AN22 18
147 
148 #define ADC_OPEN_AN0 0x0001 //AN0
149 #define ADC_OPEN_AN1 0x0002 //AN1
150 #define ADC_OPEN_AN2 0x0004 //AN2
151 #define ADC_OPEN_AN3 0x0008 //AN3
152 #define ADC_OPEN_AN4 0x0010 //AN4
153 #define ADC_OPEN_AN5 0x0020 //AN5
154 #define ADC_OPEN_AN8 0x0100 //AN8
155 #define ADC_OPEN_AN9 0x0200 //AN9
156 #define ADC_OPEN_AN10 0x0400 //AN10
157 #define ADC_OPEN_AN11 0x0800 //AN11
158 #define ADC_OPEN_AN12 0x1000 //AN12
159 #define ADC_OPEN_AN13 0x2000 //AN13
160 #define ADC_OPEN_AN14 0x4000 //AN14
161 #define ADC_OPEN_AN15 0x8000 //AN15
162 
163 
164 
165 
166 // *********************************************************************
167 // ------------------ Define ports for this board ----------------------
168 // *********************************************************************
169 
170 
171 
172 // *********************************************************************
173 // ------------------------- LEDs and Buttons --------------------------
174 // *********************************************************************
175 
176 
177 
178 // *********************************************************************
179 // ---------------- Network ENC624J600 WiFi I/O pins -------------------
180 // *********************************************************************
181 
182 
183 
184 // *********************************************************************
185 // ---------------- Network MRF24WB0M WiFi I/O pins --------------------
186 // *********************************************************************
187 
188 
189 
190 // *********************************************************************
191 // --------------------- spiFlash Configuration ------------------------
192 // *********************************************************************
193 #define SPI_FLASH_SECTOR_SIZE (4096ul)
194 //#define SPI_FLASH_PAGE_SIZE (0ul) // SST has no page boundary requirements
195 #define SPI_FLASH_PAGE_SIZE (256ul) // Winbond FLASH has 256 byte pages
196 #define SPI_FLASH_SIZE (0x400000ul) // Flash is 4MByte
197 
198 
199 
200 // *********************************************************************
201 // ----------------- SPI External FLASH and EEPROM ---------------------
202 
203 
204 
205 // *********************************************************************
206 // ----------- SPI External Mememory Bus Defines for SBC66ECL -----------
207 // *********************************************************************
208 
209 
210 
211 // *********************************************************************
212 // -------------- USB stack hardware selection options -----------------
213 // *********************************************************************
214 //This section is the set of definitions required by the MCHPFSUSB framework. These definitions
215 //tell the firmware what mode it is running in, and are required by every application developed
216 //with this revision of the MCHPFSUSB framework.
217 
218 //#define USE_SELF_POWER_SENSE_IO
219 //#define tris_self_power TRISAbits.TRISA2 // Input
220 #define self_power 1
221 
222 //#define USE_USB_BUS_SENSE_IO
223 //#define tris_usb_bus_sense TRISBbits.TRISB5 // Input
224 #define USB_BUS_SENSE U1OTGSTATbits.SESVD
225 
226 
227 
228 // *******************************************************
229 // ----------------- xEeprom Configuration -----------------
230 // ********************************************************
231 #define XEEPROM_SIZE (8192) //Default EEPROM is 25LC640 = 64kBits = 8kBytes)
232 #define XEEPROM_PAGE_SIZE (32)
233 
234 #endif