Rev 1661 Rev 1711
1 /******************************************************************** 1 /********************************************************************
2 FileName: HardwareProfile - PIC32MX460F512L PIM.h 2 FileName: HardwareProfile - PIC32MX460F512L PIM.h
3 Dependencies: See INCLUDES section 3 Dependencies: See INCLUDES section
4 Processor: PIC18 or PIC24 USB Microcontrollers 4 Processor: PIC18 or PIC24 USB Microcontrollers
5 Hardware: The code is natively intended to be used on the following 5 Hardware: The code is natively intended to be used on the following
6 hardware platforms: PICDEM™ FS USB Demo Board, 6 hardware platforms: PICDEM™ FS USB Demo Board,
7 PIC18F87J50 FS USB Plug-In Module, or 7 PIC18F87J50 FS USB Plug-In Module, or
8 Explorer 16 + PIC24 USB PIM. The firmware may be 8 Explorer 16 + PIC24 USB PIM. The firmware may be
9 modified for use on other USB platforms by editing this 9 modified for use on other USB platforms by editing this
10 file (HardwareProfile.h). 10 file (HardwareProfile.h).
11 Complier: Microchip C18 (for PIC18) or C30 (for PIC24) 11 Complier: Microchip C18 (for PIC18) or C30 (for PIC24)
12 Company: Microchip Technology, Inc. 12 Company: Microchip Technology, Inc.
13   13  
14 Software License Agreement: 14 Software License Agreement:
15   15  
16 The software supplied herewith by Microchip Technology Incorporated 16 The software supplied herewith by Microchip Technology Incorporated
17 (the “Company”) for its PIC® Microcontroller is intended and 17 (the “Company”) for its PIC® Microcontroller is intended and
18 supplied to you, the Company’s customer, for use solely and 18 supplied to you, the Company’s customer, for use solely and
19 exclusively on Microchip PIC Microcontroller products. The 19 exclusively on Microchip PIC Microcontroller products. The
20 software is owned by the Company and/or its supplier, and is 20 software is owned by the Company and/or its supplier, and is
21 protected under applicable copyright laws. All rights are reserved. 21 protected under applicable copyright laws. All rights are reserved.
22 Any use in violation of the foregoing restrictions may subject the 22 Any use in violation of the foregoing restrictions may subject the
23 user to criminal sanctions under applicable laws, as well as to 23 user to criminal sanctions under applicable laws, as well as to
24 civil liability for the breach of the terms and conditions of this 24 civil liability for the breach of the terms and conditions of this
25 license. 25 license.
26   26  
27 THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, 27 THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
28 WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED 28 WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
29 TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 29 TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
30 PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, 30 PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
31 IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR 31 IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
32 CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. 32 CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
33   33  
34 ******************************************************************** 34 ********************************************************************
35 File Description: 35 File Description:
36   36  
37 Change History: 37 Change History:
38 Rev Date Description 38 Rev Date Description
39 1.0 11/19/2004 Initial release 39 1.0 11/19/2004 Initial release
40 2.1 02/26/2007 Updated for simplicity and to use common 40 2.1 02/26/2007 Updated for simplicity and to use common
41 coding style 41 coding style
42   42  
43 ********************************************************************/ 43 ********************************************************************/
44   44  
45 #ifndef HARDWARE_PROFILE_UBW32_H 45 #ifndef HARDWARE_PROFILE_UBW32_H
46 #define HARDWARE_PROFILE_UBW32_H 46 #define HARDWARE_PROFILE_UBW32_H
47   47  
48 #include "Compiler.h" 48 #include "Compiler.h"
49   49  
50 /*******************************************************************/ 50 /*******************************************************************/
51 /*******************************************************************/ 51 /*******************************************************************/
52 /*******************************************************************/ 52 /*******************************************************************/
53 /******** Application specific definitions *************************/ 53 /******** Application specific definitions *************************/
54 /*******************************************************************/ 54 /*******************************************************************/
55 /*******************************************************************/ 55 /*******************************************************************/
56 /*******************************************************************/ 56 /*******************************************************************/
57   57  
58 /** Board definition ***********************************************/ 58 /** Board definition ***********************************************/
59 //These defintions will tell the main() function which board is 59 //These defintions will tell the main() function which board is
60 // currently selected. This will allow the application to add 60 // currently selected. This will allow the application to add
61 // the correct configuration bits as wells use the correct 61 // the correct configuration bits as wells use the correct
62 // initialization functions for the board. These defitions are only 62 // initialization functions for the board. These defitions are only
63 // required in the stack provided demos. They are not required in 63 // required in the stack provided demos. They are not required in
64 // final application design. 64 // final application design.
65   65  
66 /** CPU Clock Speed Assignment *************************************/ 66 /** CPU Clock Speed Assignment *************************************/
67 //#define RUN_AT_48MHZ 67 //#define RUN_AT_48MHZ
68 //#define RUN_AT_24MHZ 68 //#define RUN_AT_24MHZ
69 //#define RUN_AT_60MHZ 69 //#define RUN_AT_60MHZ
70 #define RUN_AT_80MHZ 70 #define RUN_AT_80MHZ
71   71  
72 // Various clock values 72 // Various clock values
73 #if defined(RUN_AT_48MHZ) 73 #if defined(RUN_AT_48MHZ)
74 #define GetSystemClock() 48000000UL 74 #define GetSystemClock() 48000000UL
75 #define GetPeripheralClock() 48000000UL 75 #define GetPeripheralClock() 48000000UL
76 #define GetInstructionClock() (GetSystemClock()) 76 #define GetInstructionClock() (GetSystemClock())
77 #elif defined(RUN_AT_24MHZ) 77 #elif defined(RUN_AT_24MHZ)
78 #define GetSystemClock() 24000000UL 78 #define GetSystemClock() 24000000UL
79 #define GetPeripheralClock() 24000000UL 79 #define GetPeripheralClock() 24000000UL
80 #define GetInstructionClock() (GetSystemClock()) 80 #define GetInstructionClock() (GetSystemClock())
81 #elif defined(RUN_AT_60MHZ) 81 #elif defined(RUN_AT_60MHZ)
82 #define GetSystemClock() (60000000ul) 82 #define GetSystemClock() (60000000ul)
83 #define GetPeripheralClock() (GetSystemClock()) 83 #define GetPeripheralClock() (GetSystemClock())
84 #define GetInstructionClock() (GetSystemClock()) 84 #define GetInstructionClock() (GetSystemClock())
85 #elif defined(RUN_AT_80MHZ) 85 #elif defined(RUN_AT_80MHZ)
86 #define GetSystemClock() (80000000ul) 86 #define GetSystemClock() (80000000ul)
87 #define GetPeripheralClock() (GetSystemClock()) 87 #define GetPeripheralClock() (GetSystemClock())
88 #define GetInstructionClock() (GetSystemClock()) 88 #define GetInstructionClock() (GetSystemClock())
89 #else 89 #else
90 #error Choose a speed 90 #error Choose a speed
91 #endif 91 #endif
92   92  
93 #define PROGRAMMABLE_WITH_USB_HID_BOOTLOADER 93 #define PROGRAMMABLE_WITH_USB_HID_BOOTLOADER
94   94  
95 /*******************************************************************/ 95 /*******************************************************************/
96 /******** USB stack hardware selection options *********************/ 96 /******** USB stack hardware selection options *********************/
97 /*******************************************************************/ 97 /*******************************************************************/
98 //This section is the set of definitions required by the MCHPFSUSB 98 //This section is the set of definitions required by the MCHPFSUSB
99 // framework. These definitions tell the firmware what mode it is 99 // framework. These definitions tell the firmware what mode it is
100 // running in, and where it can find the results to some information 100 // running in, and where it can find the results to some information
101 // that the stack needs. 101 // that the stack needs.
102 //These definitions are required by every application developed with 102 //These definitions are required by every application developed with
103 // this revision of the MCHPFSUSB framework. Please review each 103 // this revision of the MCHPFSUSB framework. Please review each
104 // option carefully and determine which options are desired/required 104 // option carefully and determine which options are desired/required
105 // for your application. 105 // for your application.
106   106  
107 //#define USE_SELF_POWER_SENSE_IO 107 //#define USE_SELF_POWER_SENSE_IO
108 #define tris_self_power TRISAbits.TRISA2 // Input 108 #define tris_self_power TRISAbits.TRISA2 // Input
109 #define self_power 1 109 #define self_power 1
110   110  
111 //#define USE_USB_BUS_SENSE_IO 111 //#define USE_USB_BUS_SENSE_IO
112 #define tris_usb_bus_sense TRISBbits.TRISB5 // Input 112 #define tris_usb_bus_sense TRISBbits.TRISB5 // Input
113 #define USB_BUS_SENSE 1 113 #define USB_BUS_SENSE 1
114   114  
115 /*******************************************************************/ 115 /*******************************************************************/
116 /******** Device revision workarounds ******************************/ 116 /******** Device revision workarounds ******************************/
117 /*******************************************************************/ 117 /*******************************************************************/
118 //Uncomment this definition to allow for revision B3 silicon to work 118 //Uncomment this definition to allow for revision B3 silicon to work
119 // with this firmware. 119 // with this firmware.
120 #define PIC32MX460F512L_REV_B3_WORKAROUND 120 #define PIC32MX460F512L_REV_B3_WORKAROUND
121 121
122 /*******************************************************************/ 122 /*******************************************************************/
123 /*******************************************************************/ 123 /*******************************************************************/
124 /*******************************************************************/ 124 /*******************************************************************/
125 /******** Application specific definitions *************************/ 125 /******** Application specific definitions *************************/
126 /*******************************************************************/ 126 /*******************************************************************/
127 /*******************************************************************/ 127 /*******************************************************************/
128 /*******************************************************************/ 128 /*******************************************************************/
129   129  
130 /** Board definition ***********************************************/ 130 /** Board definition ***********************************************/
131 //These defintions will tell the main() function which board is 131 //These defintions will tell the main() function which board is
132 // currently selected. This will allow the application to add 132 // currently selected. This will allow the application to add
133 // the correct configuration bits as wells use the correct 133 // the correct configuration bits as wells use the correct
134 // initialization functions for the board. These defitions are only 134 // initialization functions for the board. These defitions are only
135 // required in the stack provided demos. They are not required in 135 // required in the stack provided demos. They are not required in
136 // final application design. 136 // final application design.
137 #define DEMO_BOARD UBW32 137 #define DEMO_BOARD UBW32
138 #define UBW32 138 #define UBW32
139   139  
140 /** LED ************************************************************/ 140 /** LED ************************************************************/
141 #define mInitAllLEDs() LATE |= 0x000F; TRISE &= 0xFFF0; 141 #define mInitAllLEDs() LATE |= 0x000F; TRISE &= 0xFFF0;
142 142
143 #define mLED_1 LATEbits.LATE3 143 #define mLED_1 LATEbits.LATE3
144 #define mLED_2 LATEbits.LATE2 144 #define mLED_2 LATEbits.LATE2
145 #define mLED_3 LATEbits.LATE1 145 #define mLED_3 LATEbits.LATE1
146 #define mLED_4 LATEbits.LATE0 146 #define mLED_4 LATEbits.LATE0
147   147  
148 #define mGetLED_1() mLED_1 148 #define mGetLED_1() mLED_1
149 #define mGetLED_USB() mLED_1 149 #define mGetLED_USB() mLED_1
150 #define mGetLED_2() mLED_2 150 #define mGetLED_2() mLED_2
151 #define mGetLED_3() mLED_3 151 #define mGetLED_3() mLED_3
152 #define mGetLED_4() mLED_4 152 #define mGetLED_4() mLED_4
153   153  
154 #define mLED_1_On() mLED_1 = 0; 154 #define mLED_1_On() mLED_1 = 0;
155 #define mLED_USB_On() mLED_1 = 0; 155 #define mLED_USB_On() mLED_1 = 0;
156 #define mLED_2_On() mLED_2 = 0; 156 #define mLED_2_On() mLED_2 = 0;
157 #define mLED_3_On() mLED_3 = 0; 157 #define mLED_3_On() mLED_3 = 0;
158 #define mLED_4_On() mLED_4 = 0; 158 #define mLED_4_On() mLED_4 = 0;
159 159
160 #define mLED_1_Off() mLED_1 = 1; 160 #define mLED_1_Off() mLED_1 = 1;
161 #define mLED_USB_Off() mLED_1 = 1; 161 #define mLED_USB_Off() mLED_1 = 1;
162 #define mLED_2_Off() mLED_2 = 1; 162 #define mLED_2_Off() mLED_2 = 1;
163 #define mLED_3_Off() mLED_3 = 1; 163 #define mLED_3_Off() mLED_3 = 1;
164 #define mLED_4_Off() mLED_4 = 1; 164 #define mLED_4_Off() mLED_4 = 1;
165 165
166 #define mLED_1_Toggle() mLED_1 = !mLED_1; 166 #define mLED_1_Toggle() mLED_1 = !mLED_1;
167 #define mLED_USB_Toggle() mLED_1 = !mLED_1; 167 #define mLED_USB_Toggle() mLED_1 = !mLED_1;
168 #define mLED_2_Toggle() mLED_2 = !mLED_2; 168 #define mLED_2_Toggle() mLED_2 = !mLED_2;
169 #define mLED_3_Toggle() mLED_3 = !mLED_3; 169 #define mLED_3_Toggle() mLED_3 = !mLED_3;
170 #define mLED_4_Toggle() mLED_4 = !mLED_4; 170 #define mLED_4_Toggle() mLED_4 = !mLED_4;
171   171  
172 #define mLED_Both_Off() {mLED_1_Off(); mLED_2_Off();} 172 #define mLED_Both_Off() {mLED_1_Off(); mLED_2_Off();}
173 173
174 /** SWITCH *********************************************************/ 174 /** SWITCH *********************************************************/
175 #define mInitSwitch2() TRISEbits.TRISE7=1; 175 #define mInitSwitch2() TRISEbits.TRISE7=1;
176 #define mInitSwitch3() TRISEbits.TRISE6=1; 176 #define mInitSwitch3() TRISEbits.TRISE6=1;
177 #define mInitAllSwitches() mInitSwitch2();mInitSwitch3(); 177 #define mInitAllSwitches() mInitSwitch2();mInitSwitch3();
178 #define swProgram PORTEbits.RE7 178 #define swProgram PORTEbits.RE7
179 #define swUser PORTEbits.RE6 179 #define swUser PORTEbits.RE6
180   180  
181 #define UserSW swUser 181 #define UserSW swUser
182 #define sw2 swUser 182 #define sw2 swUser
183   183  
184 #define RXTX LATAbits.LATA2 184 #define RXTX LATAbits.LATA2
185   185  
186 #define BPF_S0 LATAbits.LATA0 186 #define BPF_S0 LATAbits.LATA0
187 #define BPF_S1 LATAbits.LATA1 187 #define BPF_S1 LATAbits.LATA1
188 #define BPF_S0_STATE PORTAbits.RA0 188 #define BPF_S0_STATE PORTAbits.RA0
189 #define BPF_S1_STATE PORTAbits.RA1 189 #define BPF_S1_STATE PORTAbits.RA1
190   190  
191 #define PADDLE_DIT PORTFbits.RF4 191 #define PADDLE_DIT PORTFbits.RF4
192 #define PADDLE_DAH PORTFbits.RF5 192 #define PADDLE_DAH PORTFbits.RF5
193   193  
194 #define LPF_0 LATAbits.LATA3 194 #define LPF_0 LATAbits.LATA3
195 #define LPF_1 LATAbits.LATA4 195 #define LPF_1 LATAbits.LATA4
196 #define LPF_2 LATAbits.LATA5 196 #define LPF_2 LATAbits.LATA5
197 #define LPF_3 LATAbits.LATA6 197 #define LPF_3 LATAbits.LATA6
198 #define LPF_4 LATAbits.LATA7 198 #define LPF_4 LATAbits.LATA7
199 #define LPF_5 LATAbits.LATA9 199 #define LPF_5 LATAbits.LATA9
200 #define LPF_6 LATAbits.LATA10 200 #define LPF_6 LATAbits.LATA10
201   201  
202   202  
203 #endif 203 #endif