Skip to content

Commit df55b51

Browse files
MPAE-19111 updating readme and metadata files for upgrade to XC8 v3.0 and latest MCC
1 parent cfbecc4 commit df55b51

10 files changed

+61
-45
lines changed

.main-meta/main.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@
44
"content": {
55
"metaDataVersion": "1.3.0",
66
"name": "com.microchip.mcu8.mplabx.project.pic18f57q43-dma-uart-to-pwm-part2",
7-
"version": "2.0.0",
7+
"version": "3.0.0",
88
"displayName": "DMA controlled LED dimming via Serial Stream",
99
"projectName": "pic18f57q43-dma-uart-to-pwm-part2",
1010
"shortDescription": "Part 2 example showing how to use DMA to transfer data from UART recieve buffer to PWM duty cycle register to control a PWM.",
1111
"ide": {
1212
"name": "MPLAB X",
13-
"semverRange": ">=6.15.0"
13+
"semverRange": "^6.2.0"
1414
},
1515
"compiler": [
1616
{
1717
"name": "XC8",
18-
"semverRange": "^2.45.0"
18+
"semverRange": "^3.0.0"
1919
}
2020
],
2121
"dfp": {
2222
"name": "PIC18-Q_DFP",
23-
"semverRange": "^1.3.89"
23+
"semverRange": "^1.26.442"
2424
},
2525
"configurator": {
2626
"name": "MCC",
27-
"semverRange": ">=5.5.7"
27+
"semverRange": ">=5.7.1"
2828
},
2929
"device": {
3030
"metaDataVersion": "1.0.0",

README.md

Lines changed: 56 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ This is part 2 of 2 of an example showing how to set up [Direct Memory Access (D
2828
## Software Used
2929

3030
All software used in this example is listed here:
31-
- [MPLAB® X IDE 5.30](https://www.microchip.com/mplab/mplab-x-ide?utm_campaign=PIC18FQ43&utm_source=GitHub&utm_medium=hyperlink&utm_term=&utm_content=pic18f57q43-dma-uart-to-pwm-part2-MCU8_MMTCha) or newer
32-
- [MPLAB® XC8 2.10 compiler](https://www.microchip.com/mplab/compilers?utm_campaign=PIC18FQ43&utm_source=GitHub&utm_medium=hyperlink&utm_term=&utm_content=pic18f57q43-dma-uart-to-pwm-part2-MCU8_MMTCha) or newer
33-
- [MPLAB® Code Configurator (MCC) 3.95.0](https://www.microchip.com/mplab/mplab-code-configurator?utm_campaign=PIC18FQ43&utm_source=GitHub&utm_medium=hyperlink&utm_term=&utm_content=pic18f57q43-dma-uart-to-pwm-part2-MCU8_MMTCha) or newer
31+
- [MPLAB® X IDE 6.20](https://www.microchip.com/mplab/mplab-x-ide?utm_campaign=PIC18FQ43&utm_source=GitHub&utm_medium=hyperlink&utm_term=&utm_content=pic18f57q43-dma-uart-to-pwm-part2-MCU8_MMTCha) or newer
32+
- [MPLAB® XC8 3.00 compiler](https://www.microchip.com/mplab/compilers?utm_campaign=PIC18FQ43&utm_source=GitHub&utm_medium=hyperlink&utm_term=&utm_content=pic18f57q43-dma-uart-to-pwm-part2-MCU8_MMTCha) or newer
33+
- [MPLAB® Code Configurator (MCC) 5.7.1](https://www.microchip.com/mplab/mplab-code-configurator?utm_campaign=PIC18FQ43&utm_source=GitHub&utm_medium=hyperlink&utm_term=&utm_content=pic18f57q43-dma-uart-to-pwm-part2-MCU8_MMTCha) or newer
3434
- [MCC Device Libraries PIC10 / PIC12 / PIC16 / PIC18 MCUs](https://www.microchip.com/mplab/mplab-code-configurator?utm_campaign=PIC18FQ43&utm_source=GitHub&utm_medium=hyperlink&utm_term=&utm_content=pic18f57q43-dma-uart-to-pwm-part2-MCU8_MMTCha)
35-
- [Microchip PIC18F-Q Series Device Support (1.4.109)](https://www.microchip.com/mplab/mplab-code-configurator?utm_campaign=PIC18FQ43&utm_source=GitHub&utm_medium=hyperlink&utm_term=&utm_content=pic18f57q43-dma-uart-to-pwm-part2-MCU8_MMTCha) or newer
35+
- [Microchip PIC18F-Q Series Device Support (1.26.442)](https://www.microchip.com/mplab/mplab-code-configurator?utm_campaign=PIC18FQ43&utm_source=GitHub&utm_medium=hyperlink&utm_term=&utm_content=pic18f57q43-dma-uart-to-pwm-part2-MCU8_MMTCha) or newer
3636

3737
## Hardware Used
3838
- **PIC18F57Q43 Curiosity Nano** [(DM164150)](https://www.microchip.com/Developmenttools/ProductDetails/DM164150?utm_campaign=PIC18FQ43&utm_source=GitHub&utm_medium=hyperlink&utm_term=&utm_content=pic18f57q43-dma-uart-to-pwm-part2-MCU8_MMTCha)
@@ -71,76 +71,92 @@ As noted before - this is part 2 of 2 of an example showing how to set up [Direc
7171
4. In **Choose Project** window
7272
1. Select **Microchip Embedded** category
7373
2. Select **Standalone Project**
74-
3. Hit **Next>**
74+
3. Click **Next>**
7575
5. In **Select Device** window
7676
1. Select **PIC18F57Q43** as your device
7777
2. Pro-tip: quickly filter for devices by inputting the last 3-4 characters of the device name and then selecting from the drop-down list (e.g. Q43).
78-
3. Hit **Next>**
78+
3. Click **Next>**
7979
6. In **Select Tool (Optional)** window
8080
1. If device is connected – select Microchip Kits -> PIC18F57Q43 Curiosity Nano (PKOB nano)
8181
2. If not, you can do this later when programming the device.
82-
3. Hit **Next>**
82+
3. Click **Next>**
8383
7. In **Select Compiler** window
84-
1. Select XC8 (v2.10)
85-
2. Hit **Finish**
84+
1. Select XC8 (v3.00)
85+
2. Click **Finish**
8686

8787
### Configure MCC
88-
8. In **System Module** window
89-
9. Set **Oscillator Select** to **HFINTOSC**
88+
8. In **Project Resources** under **System** select **Clock Control**
89+
9. In **Clock Control** tab, set Clock Source to **HFINTOSC**
9090
1. While this example uses a system clock of 1MHz, it should be noted that any larger value for the system clock should provide similar results.
91-
10. Under **Device Resources** left-hand pane
92-
1. Open the **Peripherals** drop-down
93-
2. Double-click the (PIC10/PIC12/…) instance of the PWM and USART3 peripherals to add them your project.
9491

9592
![](images/configure-system-clock.jpg)
9693

97-
11. In UART window/tab
98-
1. Set baud rate to 9600
94+
10. In **Project Resources** under **System** select **Configuration Bits**
95+
1. In the **Configuration Bits** tab, choose **Oscillator not enabled** under **External Oscillaotr Selection**
96+
2. Under **Reset Oscillator Selection** choose **HFINTOSC with HFFRQ = 4 MHz and CDIV = 4:1**
97+
98+
99+
11. Under **Device Resources** left-hand pane
100+
1. Open the **Drivers** drop-down
101+
2. Double-click **PWM1_16BIT** under the **PWM** drop-down to add it to your project.
102+
3. Double-click **UART3** under the **UART** drop-down to add it to your project.
103+
104+
105+
12. Click on **UART3** under the **Project Resources** pane
106+
1. In the **UART** tab, set baud rate to 9600
99107

100108
![](images/configure-uart3.jpg)
101109

102-
12. In the **PWM window** / Easy Setup tab
103-
1. Check the box next to **Enable PWM**
104-
2. In the **Registers tab**, Set **PWM1LDS to DMA1**
105-
3. **Warning:** Make this change only after doing the previous step where you configure the model in the Easy Setup window.
110+
13. In the **PWM1_16BIT window** / Easy Setup tab
111+
1. Check the Slider next to **Enable PWM**
112+
2. Choose **Left aligned mode** under the **Mode** drop-down
113+
3. Set the **Requested Frequency** to 1 KHz
106114

107115
![](images/mcc-configure-pwm-easy-view.jpg)
108116

109-
![](images/mcc-configure-pwm-register.jpg)
110117

111-
13. In the **Pin Manager: Grid View** window, connect pins:
112-
1. RX3 -> A4
113-
2. TX3 -> A3 (not needed necessarily since we are just receiving)
114-
3. PWM -> RF3 (pin tied to CNano board LED0 as per schematic)
118+
14. In the **Pin Manager: Grid View** window, connect pins:
119+
1. RX3 -> RA4
120+
2. PWM -> RF3 (pin tied to CNano board LED0 as per schematic)
121+
3. Select **Pins** under the **System** drop-down in **Project Resources**
122+
4. Make sure that the **Analog** option for RA4 and RF3 is un-checked
115123

116124
![](images/mcc-configure-pin-manager-gridview.jpg)
125+
![](images/pinsview.jpg)
117126

118-
14. In the **DMA window** manager
119-
1. Enable DMA CHANNEL 1 and make the changes shown in the table and screenshot below with explanations
120127

121-
| | Module | Region | SFR | VarName | VarSize | Address | Mode | Message Size | Start Trigger | Abort Trigger |
122-
|-----|-----------|--------|---------|---------|---------|---------|-----------|--------------|---------------|---------------|
123-
| Src | UART3 | SFR | U3RXB | - | - | - | unchanged | 1 | U3RX | None |
124-
| Dst | PWM_16bit | SFR | PWMS1P1 | - | - | - | increment | 2 | (see above) | (see above) |
128+
15. Choose **DMA1** under **Device Resources**
129+
1. In the **DMA1** tab, select **DMA Enable**
130+
2. Choose the **Start Trigger** as **U3RX**
131+
3. Turn on **Start Trigger Enable**
132+
4. Choose **SFR**, **UART3**, **U3RXB** for **Source Region**, **Source Module**, and **Source SFR** respectively
133+
5. Choose **Source Mode** as unchanged
134+
6. Set **Source Message Size** to **1**
135+
7. Choose **SFR**, **PWM1_16BIT**, and **PWM1S1P1L** for **Destination Region**, **Destination Module** and **Destination SFR** respectively
136+
8. Set **Destination Mode** to **incremented**
137+
9. Set **Destination Message Size** to **2**
125138

126139

127-
![](images/configure-dma-1.jpg)
128140

129-
![](images/configure-dma-2.jpg)
141+
![](images/configure-dma-1.jpg)
130142

131-
![](images/configure-dma-3.jpg)
132143

133-
15. What we just did:
144+
16. What we just did:
134145
1. **UART3** is the data **source module** of DMA channel 1
135146
2. **U3RXB** is the **SFR (Special function register) region** that we want data to be sourced from.
136147
3. The **U3RXB SFR register is 1-byte**, therefore the **mode is unchanged** since we don’t need to increment over multiple bytes or registers.
137148
4. Similarly, the **UART RX Buffer is 1-byte**, so we need to indicate that the **message size is 1-byte**
138149
5. **PWM1_16bit** is the data destination module, with the **PWM1S1P1L** being the specific destination SFR.
139-
6. The PWM period register is 16-bits, meaning we will need to **increment** in order to load both the low register that we started with and the PWM1S1P1H (high), which also means our **message size is 2**-bytes since we are loading two 8-bit registers.
150+
6. The PWM period register is 16-bits, meaning we will need to **increment** in order to load both the low register that we started with and the PWM1S1P1H (high), which also means our **message size** is 2 bytes since we are loading two 8-bit registers.
140151
7. Set the DMA **start trigger** to fire every time the RX Buffer is full (**U3RX**).
141-
8. **NOTE**** - we did not need to set VarSize, VarName, and Address parameters as these are only required when working with user-defined values in memory as opposed to fixed SFRs in this case.
142-
16. Hit **Generate Project** and
143-
17. Hit **Program the device** ![](images/program-device-icon.png)
152+
8. **NOTE*** we did not need to set VarSize, VarName, and Address parameters as these are only required when working with user-defined values in memory as opposed to fixed SFRs in this case.
153+
17. Click **Generate Project**
154+
18. In the `main.c` file that was generated, add the following line of code before `while(1)`:
155+
<br>
156+
`PWM1LDS = 0xB; // PWM1 auto-load trigger source is DMA1_Destination_Count_Done`
157+
This allows the PWM regsiter to be automatically loaded when the DMA transfer is complete.
158+
159+
19. Click **Program the device** ![](images/program-device-icon.png)
144160

145161
## Conclusion
146-
There you have it. You just implemented some systems coms, automatic memory operations, and waveform without writing any lines of code. Feel free to build on the project as you see fit, find more detailed applications in the documents linked in the [**resource section**](#related-documentation), or check out other code examples in the repo.
162+
There you have it. You just implemented some systems coms, automatic memory operations, and waveform while only having to write one line of code. Feel free to build on the project as you see fit, find more detailed applications in the documents linked in the [**resource section**](#related-documentation), or check out other code examples in the repo.

images/configure-dma-1.JPG

103 KB
Loading

images/configure-dma-2.JPG

-33 KB
Binary file not shown.

images/configure-dma-3.JPG

-50.4 KB
Binary file not shown.

images/configure-system-clock.JPG

49.3 KB
Loading

images/configure-uart3.jpg

10.8 KB
Loading
-27.5 KB
Loading
22 KB
Loading

images/pinsview.jpg

31.5 KB
Loading

0 commit comments

Comments
 (0)