Subversion Repositories Code-Repo

Rev

Rev 198 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 198 Rev 199
Line -... Line 1...
-
 
1
// PIC32MX795F512L
-
 
2
 
1
// Power supply must be 5V for proper operation of the board!
3
// Power supply must be 5V for proper operation of the board!
2
 
4
 
-
 
5
#define CPU_CLOCK_HZ    80000000UL
-
 
6
#define PERIPHERAL_CLOCK_HZ 80000000UL
-
 
7
#define CPU_CT_HZ       (CPU_CLOCK_HZ/2UL)
-
 
8
#define MS_TO_CT_TICKS  (CPU_CLOCK_HZ/2000UL)
-
 
9
#define US_TO_CT_TICKS  (CPU_CLOCK_HZ/2000000UL)
-
 
10
 
3
#define ADDRESS_EEPROM 0x50
11
#define ADDRESS_EEPROM 0x50
4
 
12
 
5
// BTN1 = RG6, BTN2 = RG7, BTN3 = RD13
13
// BTN1 = RG6, BTN2 = RG7, BTN3 = RD13
6
// Note: Write to PORTx is effectively the same as write to LATx
14
// Note: Write to PORTx is effectively the same as write to LATx
7
#define BTN1_TRIS TRISGbits.TRISG6
15
#define BTN1_TRIS TRISGbits.TRISG6
Line 19... Line 27...
19
#define LED3_TRIS TRISGbits.TRISG14
27
#define LED3_TRIS TRISGbits.TRISG14
20
#define LED3_PORT PORTGbits.RG14
28
#define LED3_PORT PORTGbits.RG14
21
#define LED4_TRIS TRISGbits.TRISG15
29
#define LED4_TRIS TRISGbits.TRISG15
22
#define LED4_PORT PORTGbits.RG15
30
#define LED4_PORT PORTGbits.RG15
23
 
31
 
-
 
32
void Delay_MS(unsigned int delay_ms);
-
 
33
void Delay_US(unsigned int delay_us);
-
 
34
 
24
// <editor-fold defaultstate="collapsed" desc="PMOD to MCU Pinouts">
35
// <editor-fold defaultstate="collapsed" desc="PMOD to MCU Pinouts">
25
/*
36
/*
26
JA-01	AN2/C2IN-/CN4/RB2			RB02
37
JA-01   AN2/C2IN-/CN4/RB2                               RB02
27
JA-02	AN3/C2IN+/CN5/RB3			RB03
38
JA-02   AN3/C2IN+/CN5/RB3                               RB03
28
JA-03	AN4/C1IN-/CN6/RB4			RB04
39
JA-03   AN4/C1IN-/CN6/RB4                               RB04
29
JA-04	PGEC2/AN6/OCFA/RB6			RB06
40
JA-04   PGEC2/AN6/OCFA/RB6                              RB06
30
JA-07	PGED2/AN7/RB7				RB07
41
JA-07   PGED2/AN7/RB7                                   RB07
31
JA-08	AN8/C1OUT/RB8				RB08
42
JA-08   AN8/C1OUT/RB8                                   RB08
32
JA-09	AN9/C2OUT/RB9				RB09
43
JA-09   AN9/C2OUT/RB9                                   RB09
33
JA-10	CVrefout/PMA13/AN10/RB10		RB10
44
JA-10   CVrefout/PMA13/AN10/RB10                        RB10
34
 *
45
 *
35
JB-01	PMD0/RE0				RE00
46
JB-01   PMD0/RE0                                        RE00
36
JB-02	PMD1/RE1				RE01
47
JB-02   PMD1/RE1                                        RE01
37
JB-03	PMD2/RE2				RE02
48
JB-03   PMD2/RE2                                        RE02
38
JB-04	PMD3/RE3				RE03
49
JB-04   PMD3/RE3                                        RE03
39
JB-07	PMD4/RE4				RE04
50
JB-07   PMD4/RE4                                        RE04
40
JB-08	PMD5/RE5				RE05
51
JB-08   PMD5/RE5                                        RE05
41
JB-09	PMD6/RE6				RE06
52
JB-09   PMD6/RE6                                        RE06
42
JB-10	PMD7/RE7				RE07
53
JB-10   PMD7/RE7                                        RE07
43
 *
54
 *
44
JC-01	T2CK/RC1				RC01
55
JC-01   T2CK/RC1                                        RC01
45
JC-02	C2RX/PMD8/RG0				RG00
56
JC-02   C2RX/PMD8/RG0                                   RG00
46
JC-03	C2TX/ETXERR/PMD9/RG1			RG01
57
JC-03   C2TX/ETXERR/PMD9/RG1                            RG01
47
JC-04	ETXCLK/PMD15/CN16/RD7			RD07
58
JC-04   ETXCLK/PMD15/CN16/RD7                           RD07
48
JC-07	AN15/?/OCFB/PMALL/PMA0/CN12/RB15       RB15
59
JC-07   AN15/ERXD3/AETXD2/OCFB/PMALL/PMA0/CN12/RB15     RB15    (SFT_D)
49
JC-08	PMRD/CN14/RD5				RD05
60
JC-08   PMRD/CN14/RD5                                   RD05    (SFT_S)
50
JC-09	OC5/PMWR/CN13/RD4			RD04
61
JC-09   OC5/PMWR/CN13/RD4                               RD04    (SFT_K)
51
JC-10	AN14/ERXD2/AETXD3/PMALH/PMA1/RB14       RB14
62
JC-10   AN14/ERXD2/AETXD3/PMALH/PMA1/RB14               RB14    (SFT_R)
52
 *
63
 *
53
JD-01	SS1/IC2/RD9				RD09
64
JD-01   SS1/IC2/RD9                                     RD09    (GSLAT)
54
JD-02	SDO1/OC1/INT0/RD0			RD00
65
JD-02   SDO1/OC1/INT0/RD0                               RD00    (GSSIN)
55
JD-03	T5CK/SDI1/RC4				RC04
66
JD-03   T5CK/SDI1/RC4                                   RC04    (GSSOUT)
56
JD-04	SCK1/IC3/PMCS2/PMA15/RD10		RD10
67
JD-04   SCK1/IC3/PMCS2/PMA15/RD10                       RD10    (GSSCK)
57
JD-07	OC2/RD1					RD01
68
JD-07   OC2/RD1                                         RD01    (PWMCK)
58
JD-08	OC3/RD2					RD02
69
JD-08   OC3/RD2                                         RD02    (XBLNK)
59
JD-09	OC4/RD3					RD03
70
JD-09   OC4/RD3                                         RD03    
60
JD-10	ETXD2/IC5/PMD12/RD12			RD12
71
JD-10   ETXD2/IC5/PMD12/RD12                            RD12    
61
 *
72
 *
62
JE-01	AETXD0/SS1A/U1BRX/U1ACTS/CN20/RD14	RD14
73
JE-01   AETXD0/SS3/U4RX/U1CTS/CN20/RD14                 RD14
63
JE-02	SCL1A/SDO1A/U1ATX/RF8			RF08
74
JE-02   SCL3/SDO3/U1TX/RF8                              RF08
64
JE-03	SDA1A/SDI1A/U1ARX/RF2			RF02
75
JE-03   SDA3/SDI3/U1RX/RF2                              RF02
65
JE-04	AETXD1/SCK1A/U1BTX/U1ARTS/CN21/RD15	RD15
76
JE-04   AETXD1/SCK3/U4TX/U1RTS/CN21/RD15                RD15
66
JE-07	TRCLK/RA6				RA06
77
JE-07   TRCLK/RA6                                       RA06
67
JE-08	TRD3/RA7				RA07
78
JE-08   TRD3/RA7                                        RA07
68
JE-09	Vref-/CVref-/AERXD2/PMA7/RA9            RA09
79
JE-09   Vref-/CVref-/AERXD2/PMA7/RA9                    RA09
69
JE-10	Vref+/CVref+/AERXD3/PMA6/RA10		RA10
80
JE-10   Vref+/CVref+/AERXD3/PMA6/RA10                   RA10
70
 *
81
 *
71
JF-01	AC1RX/SS3A/U3BRX/U3ACTS/RF12		RF12	shared with CAN1 Transceiver (JP-1)
82
JF-01   AC1RX/SS4/U5RX/U2CTS/RF12                       RF12    shared with CAN1 Transceiver (JP-1)
72
JF-02	SCL3A/SDO3A/U3ATX/PMA8/CN18/RF5		RF05
83
JF-02   SCL5/SDO4/U2TX/PMA8/CN18/RF5                    RF05
73
JF-03	SDA3A/SDI3A/U3ARX/PMA9/CN17/RF4		RF04
84
JF-03   SDA5/SDI4/U2RX/PMA9/CN17/RF4                    RF04
74
JF-04	AC1TX/SCK3A/U3BTX/U3ARTS/RF13		RF13	shared with CAN1 Transceiver (JP-2)
85
JF-04   AC1TX/SCK4/U5TX/U2RTS/RF13                      RF13    shared with CAN1 Transceiver (JP-2)
75
JF-07	TMS/RA0					RA00
86
JF-07   TMS/RA0                                         RA00
76
JF-08	TCK/RA1					RA01
87
JF-08   TCK/RA1                                         RA01
77
JF-09	TDI/RA4					RA04
88
JF-09   TDI/RA4                                         RA04
78
JF-10	TDO/RA5					RA05
89
JF-10   TDO/RA5                                         RA05
79
 
90
 
80
N/A	SCL2/RA2				RA02	I2C bus #2, not shared with Pmod connector
91
N/A SCL2/RA2                                                        RA02    I2C bus #2, not shared with Pmod connector
81
N/A	SDA2/RA3				RA03	I2C bus #2, not shared with Pmod connector
92
N/A SDA2/RA3                                                        RA03    I2C bus #2, not shared with Pmod connector
82
N/A	AETXCLK/SCL1/INT3/RA14			RA14	I2C Bus #1, not shared with Pmod connector
93
N/A AETXCLK/SCL1/INT3/RA14                                          RA14    I2C Bus #1, not shared with Pmod connector
83
N/A	AETXEN/SDA1/INT4/RA15			RA15	I2C Bus #1, not shared with Pmod connector
94
N/A AETXEN/SDA1/INT4/RA15                                           RA15    I2C Bus #1, not shared with Pmod connector
84
N/A	PGED1/AN0/CN2/RB0			RB00	Used by debug circuit, PGC
95
N/A PGED1/AN0/CN2/RB0                                               RB00    Used by debug circuit, PGC
85
N/A	PGEC1/AN1/CN3/RB1			RB01	Used by debug circuit, PGD
96
N/A PGEC1/AN1/CN3/RB1                                               RB01    Used by debug circuit, PGD
86
N/A	AN5/C1IN+/VBUSON/CN7/RB5		RB05	USB VBUSON
97
N/A AN5/C1IN+/VBUSON/CN7/RB5                                        RB05    USB VBUSON
87
N/A	AN11/ERXERR/AETXERR/PMA12/RB11		RB11	Ethernet PHY
98
N/A AN11/ERXERR/AETXERR/PMA12/RB11                                  RB11    Ethernet PHY
88
N/A	AN12/ERXD0/AECRS/PMA11/RB12		RB12	Ethernet PHY
99
N/A AN12/ERXD0/AECRS/PMA11/RB12                                     RB12    Ethernet PHY
89
N/A	AN13/ERXD1/AECOL/PMA10/RB13		RB13	Ethernet PHY
100
N/A AN13/ERXD1/AECOL/PMA10/RB13                                     RB13    Ethernet PHY
90
N/A	OSC1/CLKI/RC12				RC12	Primary Oscillator Crystal
101
N/A OSC1/CLKI/RC12                                                  RC12    Primary Oscillator Crystal
91
N/A	SOSCI/CN1/RC13				RC13	Secondary Oscillator Crystal
102
N/A SOSCI/CN1/RC13                                                  RC13    Secondary Oscillator Crystal
92
N/A	SOSCO/T1CK/CN0/RC14			RC14	Secondary Oscillator Crystal
103
N/A SOSCO/T1CK/CN0/RC14                                             RC14    Secondary Oscillator Crystal
93
N/A	OSC2/CLKO/RC15				RC15	Primary Oscillator Crystal
104
N/A OSC2/CLKO/RC15                                                  RC15    Primary Oscillator Crystal
94
N/A	ETXEN/PMD14/CN15/RD6			RD06	Ethernet PHY
105
N/A ETXEN/PMD14/CN15/RD6                                            RD06    Ethernet PHY
95
N/A	RTCC/EMDIO/AEMDIO/IC1/RD8		RD08	Ethernet PHY
106
N/A RTCC/EMDIO/AEMDIO/IC1/RD8                                       RD08    Ethernet PHY
96
N/A	EMDC/AEMDC/IC4/PMCS1/PMA14/RD11		RD11	Ethernet PHY
107
N/A EMDC/AEMDC/IC4/PMCS1/PMA14/RD11                                 RD11    Ethernet PHY
97
N/A	ETXD3/PMD13/CN19/RD13			RD13	BTN3
108
N/A ETXD3/PMD13/CN19/RD13                                           RD13    BTN3
98
N/A	AERXD0/INT1/RE8				RE08	USB Overcurrent detect
109
N/A AERXD0/INT1/RE8                                                 RE08    USB Overcurrent detect
99
N/A	AERXD1/INT2/RE9				RE09	Ethernet PHY Reset
110
N/A AERXD1/INT2/RE9                                                 RE09    Ethernet PHY Reset
100
N/A	C1RX/ETXD1/PMD11/RF0			RF00	Ethernet PHY
111
N/A C1RX/ETXD1/PMD11/RF0                                            RF00    Ethernet PHY
101
N/A	C1TX/ETXD0/PMD10/RF1			RF01	Ethernet PHY
112
N/A C1TX/ETXD0/PMD10/RF1                                            RF01    Ethernet PHY
102
N/A	USBID/RF3				RF03	USBID (USB-4)
113
N/A USBID/RF3                                                       RF03    USBID (USB-4)
103
N/A	D+/RG2					RG02	D+ (USB-3)
114
N/A D+/RG2                                                          RG02    D+ (USB-3)
104
N/A	D-/RG3					RG03	D- (USB-2)
115
N/A D-/RG3                                                          RG03    D- (USB-2)
105
N/A	ECOL/SCK2A/U2BTX/U2ARTS/PMA5/CN8/RG6	RG06	BTN1
116
N/A ECOL/SCK2/U6TX/U3RTS/PMA5/CN8/RG6                               RG06    BTN1
106
N/A	ECRS/SDA2A/SDI2A/U2ARX/PMA4/CN9/RG7	RG07	BTN2
117
N/A ECRS/SDA4/SDI2/U3RX/PMA4/CN9/RG7                                RG07    BTN2
107
N/A	?/SCL2A/SDO2A/U2ATX/PMA3/CN10/RG8	RG08	Ethernet PHY
118
N/A ERXDV/AERXDV/ECRSDV/AECRSDV/SCL4/SDO2/U3TX/PMA3/CN10/RG8        RG08    Ethernet PHY
108
N/A	?/SS2A/U2BRX/U2ACTS/PMA2/CN11/RG9	RG09	Ethernet PHY
119
N/A ERXCLK/AERXCLK/EREFCLK/AEREFCLK/SS2/U6RX/U3CTS/PMA2/CN11/RG9    RG09    Ethernet PHY
109
N/A	TRD1/RG12				RG12	LED1
120
N/A TRD1/RG12                                                       RG12    LED1
110
N/A	TRD0/RG13				RG13	LED2
121
N/A TRD0/RG13                                                       RG13    LED2
111
N/A	TRD2/RG14				RG14	LED3
122
N/A TRD2/RG14                                                       RG14    LED3
112
N/A	AERXERR/RG15				RG15	LED4
123
N/A AERXERR/RG15                                                    RG15    LED4
113
 */
124
 */
114
// </editor-fold>
125
// </editor-fold>
115
 
126
 
116
// <editor-fold defaultstate="collapsed" desc="Connectors">
127
// <editor-fold defaultstate="collapsed" desc="Connectors">
117
/*
128
/*
Line 130... Line 141...
130
J15 - Debug USB Connector
141
J15 - Debug USB Connector
131
 * This connector is used to connect the on-board programming and
142
 * This connector is used to connect the on-board programming and
132
    debug circuit to the PC for use with the MPLAB IDE.
143
    debug circuit to the PC for use with the MPLAB IDE.
133
J16 - Power supply source select
144
J16 - Power supply source select
134
 * This jumper is used to select the source of main board power.
145
 * This jumper is used to select the source of main board power.
135
	Place a shorting block in the upper, ?USB? position to have the
146
    Place a shorting block in the upper, ?USB? position to have the
136
            board powered from the USB device connector, J19.
147
            board powered from the USB device connector, J19.
137
	Place a shorting block in the center, ?EXT? position to have the
148
    Place a shorting block in the center, ?EXT? position to have the
138
            board powered from one of the external power connectors, J17 or J18.
149
            board powered from one of the external power connectors, J17 or J18.
139
	Place a shorting block in the lower, ?DBG? position to have the
150
    Place a shorting block in the lower, ?DBG? position to have the
140
            board powered from the debug USB connector, J15.
151
            board powered from the debug USB connector, J15.
141
J17 - External Power Connector
152
J17 - External Power Connector
142
 * This is a 2.5mm x 5.5mm, center positive, coax power connector used to 
153
 * This is a 2.5mm x 5.5mm, center positive, coax power connector used to
143
    provide external power to the board. The optional Digilent 5V Switching
154
    provide external power to the board. The optional Digilent 5V Switching
144
    Power Supply is connected here.
155
    Power Supply is connected here.
145
J18 - External Power Connector
156
J18 - External Power Connector
146
 * This is a screw terminal connector used to provide external power to
157
 * This is a screw terminal connector used to provide external power to
147
    the board. Be sure to observe proper polarity (marked near the connector)
158
    the board. Be sure to observe proper polarity (marked near the connector)
Line 149... Line 160...
149
    connected devices may result.
160
    connected devices may result.
150
J19 - USB Device / OTG Connector
161
J19 - USB Device / OTG Connector
151
 * This is a USB micro-AB connector. It is used when using the PIC32MX795
162
 * This is a USB micro-AB connector. It is used when using the PIC32MX795
152
    microcontroller to implement a USB device or OTG Host/Device.
163
    microcontroller to implement a USB device or OTG Host/Device.
153
J20 - USB Host Connector
164
J20 - USB Host Connector
154
 * This is a standard sized USB type A connector. This connector is used to 
165
 * This is a standard sized USB type A connector. This connector is used to
155
    connect USB devices to the board when using the PIC32MX795 microcontroller
166
    connect USB devices to the board when using the PIC32MX795 microcontroller
156
    to implement an embedded USB host.
167
    to implement an embedded USB host.
157
 */
168
 */
158
// </editor-fold>
169
// </editor-fold>
159
 
170
 
160
// <editor-fold defaultstate="collapsed" desc="Jumpers">
171
// <editor-fold defaultstate="collapsed" desc="Jumpers">
161
/*
172
/*
162
J20 - USB Host Connector
173
J20 - USB Host Connector
163
 * This is a standard sized USB type A connector. This connector is used to 
174
 * This is a standard sized USB type A connector. This connector is used to
164
    connect USB devices to the board when using the PIC32MX795 microcontroller
175
    connect USB devices to the board when using the PIC32MX795 microcontroller
165
    to implement an embedded USB host.
176
    to implement an embedded USB host.
166
JP1 & JP2 - CAN or Pmod Select
177
JP1 & JP2 - CAN or Pmod Select
167
 * These jumpers select microcontroller signals RF12 and RF13 for use with CAN 
178
 * These jumpers select microcontroller signals RF12 and RF13 for use with CAN
168
    #1 or Pmod connector JF. Place these jumpers in the CAN position to use CAN
179
    #1 or Pmod connector JF. Place these jumpers in the CAN position to use CAN
169
    #1. Place the jumpers in the PMOD position to use then with Pmod connector JF.
180
    #1. Place the jumpers in the PMOD position to use then with Pmod connector JF.
170
JP3 & JP4 - Pull-up enable for I2C port #2
181
JP3 & JP4 - Pull-up enable for I2C port #2
171
 * These two jumpers are used to enable/disable the pull-up resistors on I2C
182
 * These two jumpers are used to enable/disable the pull-up resistors on I2C
172
    port #2. Insert shorting blocks on these two jumpers to enable the pull-up
183
    port #2. Insert shorting blocks on these two jumpers to enable the pull-up
173
    resistors. Remove the shorting blocks to disable the pull-up resistors. Only
184
    resistors. Remove the shorting blocks to disable the pull-up resistors. Only
174
    a single device on the I2C bus should have the pull-up resistors enabled.
185
    a single device on the I2C bus should have the pull-up resistors enabled.
175
JP5 - CAN #1 Termination
186
JP5 - CAN #1 Termination
176
 * This jumper is used to enable/disable the 120 ohm termination resistor for 
187
 * This jumper is used to enable/disable the 120 ohm termination resistor for
177
    CAN #1. Insert the shorting block to enable the termination resistor, remove
188
    CAN #1. Insert the shorting block to enable the termination resistor, remove
178
    it to disable the termination resistor.
189
    it to disable the termination resistor.
179
JP6 - CAN #1 5V0 Enable
190
JP6 - CAN #1 5V0 Enable
180
 * This jumper is used to enable/disable providing 5V to the CAN #1 connector. 
191
 * This jumper is used to enable/disable providing 5V to the CAN #1 connector.
181
    Insert the shorting block to connect the board 5V0 supply to pins 9 & 10 of
192
    Insert the shorting block to connect the board 5V0 supply to pins 9 & 10 of
182
    CAN #1 connector. Remove the shorting block to disconnect the 5V0 supply.
193
    CAN #1 connector. Remove the shorting block to disconnect the 5V0 supply.
183
JP7 - CAN #2 Termination
194
JP7 - CAN #2 Termination
184
 * This jumper is used to enable/disable the 120 ohm termination resistor for 
195
 * This jumper is used to enable/disable the 120 ohm termination resistor for
185
    CAN #2. Insert the shorting block to enable the termination resistor, remove
196
    CAN #2. Insert the shorting block to enable the termination resistor, remove
186
    it to disable the termination resistor.
197
    it to disable the termination resistor.
187
JP8 - CAN #1 5V0 Enable
198
JP8 - CAN #1 5V0 Enable
188
 * This jumper is used to enable/disable providing 5V to the CAN #1 connector. 
199
 * This jumper is used to enable/disable providing 5V to the CAN #1 connector.
189
    Insert the shorting block to connect the board 5V0 supply to pins 9 & 10 of
200
    Insert the shorting block to connect the board 5V0 supply to pins 9 & 10 of
190
    CAN #1 connector. Remove the shorting block to disconnect the 5V0 supply.
201
    CAN #1 connector. Remove the shorting block to disconnect the 5V0 supply.
191
JP9 - Do Not Use
202
JP9 - Do Not Use
192
JP10 - USB host power select
203
JP10 - USB host power select
193
 * This jumper is used to select which host connector is powered when host power
204
 * This jumper is used to select which host connector is powered when host power