You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+57-45
Original file line number
Diff line number
Diff line change
@@ -5,19 +5,22 @@
5
5
In this example, the ADCC will be configured to sample the Temperature Indicator Module in order to measure the device temperature of a PIC18F16Q41 microcontroller.
- MPLAB® X IDE v6.20.0 or newer [(MPLAB X IDE 5.45)](https://www.microchip.com/en-us/development-tools-tools-and-software/mplab-x-ide?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_pic18q41&utm_content=pic18f16q41-adcc-temp-sensor-mplab-mcc-github)
17
-
- MPLAB XC8 v3.0.0 or newer compiler [(MPLAB XC8 v3.0.0)](https://www.microchip.com/en-us/development-tools-tools-and-software/mplab-xc-compilers?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_pic18q41&utm_content=pic18f16q41-adcc-temp-sensor-mplab-mcc-github)
*[MPLAB Data Visualizer Plugin](https://www.microchip.com/en-us/development-tools-tools-and-software/embedded-software-center/mplab-data-visualizer?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_pic18q41&utm_content=pic18f16q41-adcc-temp-sensor-mplab-mcc-github) or other serial terminal
16
+
17
+
18
+
-[MPLAB® X IDE v6.20.0 or newer](https://www.microchip.com/en-us/development-tools-tools-and-software/mplab-x-ide?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_pic18q41&utm_content=pic18f16q41-adcc-temp-sensor-mplab-mcc-github)
19
+
-[MPLAB XC8 v3.0.0 or newer compiler](https://www.microchip.com/en-us/development-tools-tools-and-software/mplab-xc-compilers?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_pic18q41&utm_content=pic18f16q41-adcc-temp-sensor-mplab-mcc-github)
-[MPLAB Data Visualizer Plugin](https://www.microchip.com/en-us/development-tools-tools-and-software/embedded-software-center/mplab-data-visualizer?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_pic18q41&utm_content=pic18f16q41-adcc-temp-sensor-mplab-mcc-github) or other serial terminal
23
+
21
24
22
25
23
26
## Hardware Used
@@ -28,15 +31,15 @@ In this example, the ADCC will be configured to sample the Temperature Indicator
28
31
29
32
**Step #1: Creating the Project**
30
33
31
-
+ On the tool bar, click on New Project
34
+
+ On the tool bar, click New Project
32
35
+ Microchip Embedded; Standalone Project
33
36
+ Enter the Device
34
37
+ For this Project: PIC18F16Q41
35
38
+ Enter a name for this project, such as *adcc-temp-sensor*
36
39
+ Name: “adcc-temp-sensor”
37
-
+**Note: The project name cannot have any empty spaces**
40
+
+**Note**: The project name cannot have any empty spaces
38
41
39
-
**Step #2: MPLAB Code Configurator (MCC)**
42
+
**Step #2: MPLAB Code Configurator (MCC)**
40
43
41
44
+ Modify the Clock Control
42
45
+ Set “Clock Source” to High Frequency Internal Oscillator (HFINTOSC)
@@ -47,45 +50,53 @@ In this example, the ADCC will be configured to sample the Temperature Indicator
47
50
48
51
49
52
+ Set Configuration Bits
50
-
+ Disable "External Oscillator Mode Selection"
51
-
+ Set "Power-up Default Value for COSC" to "HFINTOSC with HFFRQ = 64MHz and CDIV = 1:1"
52
-
+ Ensure that "WDT Operating Mode" is set to "WDT Disabled; SWDTEN is ignored"
53
+
+ Disable "External Oscillator Mode Selection" in CONFIG 1
54
+
+ Set "Power-up Default Value for COSC" in CONFIG 1 to "HFINTOSC with HFFRQ = 64MHz and CDIV = 1:1"
55
+
+ Ensure that "WDT Operating Mode" in CONFIG 5 is set to "WDT Disabled; SWDTEN is ignored"
53
56
54
57

55
58
56
59
57
-
**Step #3: Adding ADCC, FVR, Memory, Timer, and UART peripherals**
60
+
**Step #3: Adding ADCC, FVR, Memory, Timer, and UART Peripherals**
58
61
59
62
For this project to work properly, the application goes through a specific series of steps to minimize noise in the measurement.
60
-
- These steps are: ADCC is set up to run periodically from hardware trigger → Device is put to sleep → Hardware trigger activates → Temperature Sensor is measured multiple times and averaged → Microcontroller is woken up after average is computed → Result is converted to temperature → Print results using UART.
63
+
64
+
These steps are:
65
+
1. Analog-to-Digital Converter with Computation (ADCC) is set up to run periodically from a hardware trigger
66
+
2. The device is put to sleep
67
+
3. The hardware trigger activates
68
+
4. The temperature sensor is measured multiple times and averaged
69
+
5. The microcontroller is woken up after the average is computed
70
+
6. The result is converted to temperature
71
+
7. The results are printed using UART
61
72
62
73
+ In Device Resources:
63
-
+ Drivers→ADCC→ADCC
64
-
+ Drivers→FVR→FVR
65
-
+ Drivers→Memory→MEMORY
66
-
+ Drivers→Timer→TMR2
67
-
+ Drivers→UART→UART1
74
+
+ Drivers>ADCC>ADCC
75
+
+ Drivers>FVR>FVR
76
+
+ Drivers>Memory>MEMORY
77
+
+ Drivers>Timer>TMR2
78
+
+ Drivers>UART>UART1
68
79
69
80

70
81
71
82
72
-
**Once the peripherals are added, modify the peripherals:**
83
+
Once the peripherals are added, change to following settings:
73
84
74
-
Please refer to the Temperature Indicator Module on the [PIC18F16Q41 Datasheet](https://ww1.microchip.com/downloads/en/DeviceDoc/PIC18F06-16Q41-DataSheet-40002214C.pdf) when configuring these peripherals.
85
+
Please refer to the Temperature Indicator Module on the [PIC18F16Q41 data sheet](https://ww1.microchip.com/downloads/en/DeviceDoc/PIC18F06-16Q41-DataSheet-40002214C.pdf) when configuring these peripherals.
@@ -117,42 +128,43 @@ For this project to work properly, the application goes through a specific serie
117
128
+***ADC Threshold is enabled***
118
129
119
130

131
+
120
132

121
133
122
134
+ UART1
123
135
+ Software Settings:
124
-
+ Enable "Redirect STDIO to UART" in order to use the function (printf) for sending messages.
136
+
+ Enable "Redirect STDIO to UART" in order to use the function (printf) for sending messages
125
137
+ Hardware Settings:
126
-
+ Enable UART box should be checked
127
-
+ Enable transmit and Receive should be checked
138
+
+ Enable UART box must be checked
139
+
+ Enable transmit and Receive must be checked
128
140
+ Set the Baud Rate to 19200
129
141
+ Everything else can be left as default settings
130
142
131
143

132
144
133
145
134
146
135
-
+***In order for the Temperature calculation to be made, gain and offset need to be read from the Device Information Area (DIA). By configuring the memory peripheral this allows access to read those values.***
147
+
+ In order for the temperature calculation to be made, gain and offset need to be read from the Device Information Area (DIA). By configuring the memory peripheral, this allows access to read those values.
136
148
+ Memory
137
-
+***Custom Name:*** FLASH
138
-
+***Add Data EE Routines:*** Enabled
149
+
+ Custom Name: FLASH
150
+
+ Add Data EE Routines: Enabled
139
151
140
152

141
153
142
154
143
155
**Step #4: Configure the Pins**
144
-
+**TX1** is connected to pin RB7
145
-
+**RX1** is connected to pin RB5
156
+
+ TX1 is connected to pin RB7
157
+
+ RX1 is connected to pin RB5
146
158
147
159

148
160
149
-
**Step #5: Generate the project**
150
-
+ Click the generate button in MCC to create the appropriate header and source files for this configuration
161
+
**Step #5: Generate the Project**
162
+
+ Click the **generate** button in MCC to create the appropriate header and source files for this configuration
151
163
152
164
153
165
**Step #6: Modifying main.c**
154
-
+Upon the generation being completed, the new MCC generated header and source files will be in the project window. Select the main.c file and you will see an empty while(1) loop where you can add your application code.
155
-
+ Refer to section 39.2 on the [PIC18F16Q41 Datasheet](https://ww1.microchip.com/downloads/en/DeviceDoc/PIC18F06-16Q41-DataSheet-40002214C.pdf) to fully understand the Temperature Calculation
166
+
+Once the project is generated, the new MCC generated header and source files will be in the project window. Select the `main.c` file and you will see an empty while(1) loop where you can add your application code.
167
+
+ Refer to section 39.2 on the [PIC18F16Q41 data sheet](https://ww1.microchip.com/downloads/en/DeviceDoc/PIC18F06-16Q41-DataSheet-40002214C.pdf) to fully understand the temperature calculation
156
168
157
169
```
158
170
#include "mcc_generated_files/system/system.h"
@@ -198,20 +210,20 @@ int main(void)
198
210
199
211
200
212
**Step #7: MPLAB Data Visualizer**
201
-
+ Open up the Data Visualizer on the host computer and select the COM port associated with the Curiosity Nano.
213
+
+ Open up the Data Visualizer on the host computer and select the COM port associated with the Curiosity Nano
202
214
203
215

204
216
205
-
+ Ensure that the Terminal tab is selected
217
+
+ Ensure that the **Terminal** tab is selected
206
218
207
219

208
220
209
-
+ Once selected, configure the data visualizer to communicate at 19200 baud, no parity, and 1 stop bit.
221
+
+ Once selected, configure the data visualizer to communicate at: 19200 baud, no parity, and 1 stop bit
210
222
211
223

212
224
213
-
+ If everything is setup correctly, then the Data Visualizer should start displaying the device temperature every half a second.
214
-
+ If you cover or touch the die on the device, you will notice the temperature start to increase.
225
+
+ If everything is set up correctly, then the Data Visualizer will start displaying the device temperature every half a second
226
+
+ If you cover or touch the DIE on the device, you will notice the temperature start to increase
0 commit comments