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
+56-40Lines changed: 56 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,11 +28,11 @@ This is part 2 of 2 of an example showing how to set up [Direct Memory Access (D
28
28
## Software Used
29
29
30
30
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
-[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
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**
125
138
126
139
127
-

128
140
129
-

141
+

130
142
131
-

132
143
133
-
15. What we just did:
144
+
16. What we just did:
134
145
1.**UART3** is the data **source module** of DMA channel 1
135
146
2.**U3RXB** is the **SFR (Special function register) region** that we want data to be sourced from.
136
147
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.
137
148
4. Similarly, the **UART RX Buffer is 1-byte**, so we need to indicate that the **message size is 1-byte**
138
149
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 2bytes since we are loading two 8-bit registers.
140
151
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**
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**
144
160
145
161
## 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.
0 commit comments