Skip to content

Commit 76dd465

Browse files
committed
MPAE-18443: Code updates
1 parent b751dd6 commit 76dd465

File tree

17 files changed

+298
-253
lines changed

17 files changed

+298
-253
lines changed

.main-meta/main.json

Lines changed: 51 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,54 @@
11
{
2-
"metaDataVersion": "1.0.0",
3-
"category": "com.microchip.ide.project",
4-
"content": {
5-
"metaDataVersion": "1.3.0",
6-
"name": "com.microchip.mcu8.mplabx.project.pic16f13145-multiple-clb-configurations-mplab-mcc",
7-
"version": "1.0.0",
8-
"displayName": "Getting Started with Multiple Configurations for the Configurable Logic Block (CLB) - Use Case for the PIC16F13145 Microcontroller with MCC Melody",
9-
"projectName": "pic16f13145-multiple-clb-configurations-mplab-mcc",
10-
"shortDescription": "This repository provides an MPLAB X project highlighting how different bitstream configurations for the Configurable Logic Block (CLB) peripheral can be changed and loaded at runtime.",
11-
"ide": {
12-
"name": "MPLAB X",
13-
"semverRange": ">=6.15.0"
14-
},
15-
"compiler": [
16-
{
17-
"name": "XC8",
18-
"semverRange": "^2.45.0"
19-
}
20-
],
21-
"dfp": {
22-
"name": "PIC16F1xxxx_DFP",
23-
"semverRange": "^1.23.382"
24-
},
25-
"configurator": {
26-
"name": "MCC",
27-
"semverRange": ">=5.4.1"
28-
},
29-
"device": {
30-
"metaDataVersion": "1.0.0",
31-
"category": "com.microchip.portal.contentRef",
32-
"content": {
33-
"metaDataVersion": "1.0.0",
34-
"category": "com.microchip.device",
35-
"name": "PIC16F13145",
36-
"versionRange": "*"
37-
}
38-
},
39-
"author": "Cristian Cristea",
40-
"peripherals": [
41-
"CLB",
42-
"NVMCTRL",
43-
"CRC"
44-
],
45-
"keywords": [
46-
"CLB",
47-
"Melody"
48-
],
49-
"additionalData": {
50-
"longDescription": {
51-
"metaDataVersion": "1.0.0",
52-
"category": "com.microchip.portal.fileRef",
53-
"content": {
54-
"metaDataVersion": "1.0.0",
55-
"fileName": "./README.md",
56-
"mimeType": "text/markdown"
57-
}
58-
}
2+
"metaDataVersion": "1.0.0",
3+
"category": "com.microchip.ide.project",
4+
"content": {
5+
"metaDataVersion": "1.3.0",
6+
"name": "com.microchip.mcu8.mplabx.project.pic16f13145-multiple-clb-configurations-mplab-mcc",
7+
"version": "1.1.0",
8+
"displayName": "Getting Started with Multiple Configurations for the Configurable Logic Block (CLB) - Use Case for the PIC16F13145 Microcontroller with MCC Melody",
9+
"projectName": "pic16f13145-multiple-clb-configurations-mplab-mcc",
10+
"shortDescription": "This repository provides an MPLAB X project highlighting how different bitstream configurations for the Configurable Logic Block (CLB) peripheral can be changed and loaded at runtime.",
11+
"ide": {
12+
"name": "MPLAB X",
13+
"semverRange": ">=6.20.0"
14+
},
15+
"compiler": [
16+
{
17+
"name": "XC8",
18+
"semverRange": "^2.50.0"
19+
}
20+
],
21+
"dfp": {
22+
"name": "PIC16F1xxxx_DFP",
23+
"semverRange": "^1.25.389"
24+
},
25+
"configurator": {
26+
"name": "MCC",
27+
"semverRange": ">=5.7.1"
28+
},
29+
"device": {
30+
"metaDataVersion": "1.0.0",
31+
"category": "com.microchip.portal.contentRef",
32+
"content": {
33+
"metaDataVersion": "1.0.0",
34+
"category": "com.microchip.device",
35+
"name": "PIC16F13145",
36+
"versionRange": "*"
37+
}
38+
},
39+
"author": "Cristian Cristea",
40+
"peripherals": ["CLB", "NVMCTRL", "CRC"],
41+
"keywords": ["CLB", "Melody"],
42+
"additionalData": {
43+
"longDescription": {
44+
"metaDataVersion": "1.0.0",
45+
"category": "com.microchip.portal.fileRef",
46+
"content": {
47+
"metaDataVersion": "1.0.0",
48+
"fileName": "./README.md",
49+
"mimeType": "text/markdown"
5950
}
51+
}
6052
}
61-
}
53+
}
54+
}

README.md

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</picture>
77
</a>
88

9-
# Getting Started With Multiple Configurations for the Configurable Logic Block (CLB) – Use Case for the PIC16F13145 Microcontroller With MCC Melody
9+
# Getting Started With Multiple Configurations for the Configurable Logic Block (CLB) – Use Case for the PIC16F13145 Microcontroller with MCC Melody
1010

1111
The PIC16F13145 device family of microcontrollers is equipped with a Configurable Logic Block (CLB) peripheral. The CLB is a collection of logic elements that can be programmed to perform a wide variety of digital logic functions. The logic function may be completely combinatorial, sequential or a combination of the two, enabling users to incorporate hardware-based custom logic into their applications. This peripheral presents a unique way of modifying its control registers and setting up the logic elements. The CLB module consists of two sets of register interfaces: the standard Special Function Register (SFR) interface and a Configuration Interface. These SFRs allow user software the ability to enable/disable the module, program input bits into the CLB memory, select a clock source, read the outputs of each Basic Logic Element (BLE) and enable Peripheral Pin Select (PPS) outputs for specific BLE outputs.
1212

@@ -20,15 +20,14 @@ This code example shows how to change the bitstream at run-time and will reconfi
2020
- [PIC16F13145 Product Page](https://www.microchip.com/en-us/product/PIC16F13145?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_PIC16F13145&utm_content=pic16f13145-multiple-clb-configurations-mplab-mcc-github&utm_bu=MCU08)
2121
- [PIC16F13145 Data Sheet](https://ww1.microchip.com/downloads/aemDocuments/documents/MCU08/ProductDocuments/DataSheets/PIC16F13145-Family-Microcontroller-Data-Sheet-DS40002519.pdf)
2222
- [PIC16F13145 Curiosity Nano](https://www.microchip.com/en-us/development-tool/EV06M52A?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_PIC16F13145&utm_content=pic16f13145-multiple-clb-configurations-mplab-mcc-github&utm_bu=MCU08)
23-
- [PIC16F13145 Content on MPLAB® Discover](https://mplab-discover.microchip.com/v2?dsl=PIC16F13145)
23+
- [PIC16F13145 Code Examples on Discover](https://mplab-discover.microchip.com/v2?dsl=PIC16F13145)
2424
- [PIC16F13145 Code Examples on GitHub](https://github.com/orgs/microchip-pic-avr-examples/repositories?q=pic16f13145&type=all)
2525

2626
## Software Used
2727

28-
- [MPLAB X IDE v6.15 or newer](https://www.microchip.com/en-us/tools-resources/develop/mplab-x-ide?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_PIC16F13145&utm_content=pic16f13145-multiple-clb-configurations-mplab-mcc-github&utm_bu=MCU08)
29-
- [MPLAB XC8 v2.46 or newer](https://www.microchip.com/en-us/tools-resources/develop/mplab-xc-compilers?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_PIC16F13145&utm_content=pic16f13145-multiple-clb-configurations-mplab-mcc-github&utm_bu=MCU08)
30-
- [MPLAB Code Configurator (MCC) Melody](https://www.microchip.com/en-us/tools-resources/configure/mplab-code-configurator?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_PIC16F13145&utm_content=pic16f13145-multiple-clb-configurations-mplab-mcc-github&utm_bu=MCU08)
31-
- [PIC16F1xxxx_DFP Device Family Pack v1.24.387 or newer](https://packs.download.microchip.com/)
28+
- [MPLAB® X IDE v6.20 or newer](https://www.microchip.com/en-us/tools-resources/develop/mplab-x-ide?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_PIC16F13145&utm_content=pic16f13145-multiple-clb-configurations-mplab-mcc-github&utm_bu=MCU08)
29+
- [MPLAB XC8 v2.50 or newer](https://www.microchip.com/en-us/tools-resources/develop/mplab-xc-compilers?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_PIC16F13145&utm_content=pic16f13145-multiple-clb-configurations-mplab-mcc-github&utm_bu=MCU08)
30+
- [PIC16F1xxxx_DFP Device Family Pack v1.25.389 or newer](https://packs.download.microchip.com/)
3231

3332
## Hardware Used
3433

@@ -63,18 +62,18 @@ The main point of this example is showing the changes that must be made to the b
6362
After the file has been renamed, the labels that delimit the sequence of data words and the name of the Program Section have to be changed so that they are unique for every bitstream assembly file, as demonstrated in the diagram below. Finally, the user can implement a new digital design, synthesize it and generate a new bitstream file through the MCC. The process can be reiterated however many times it is needed to create the required number of bitstream files.
6463

6564
<picture>
66-
<img alt="Shows an MPLAB® Code Configurator (MCC) Configuration for the System Clock" src="images/diff.svg" width="600">
65+
<img alt="Shows an MPLAB Code Configurator (MCC) Configuration for the System Clock" src="images/diff.svg" width="600">
6766
</picture>
6867

6968
### Additional MCC Configurations
7069

71-
The CLB Module in the MCC also features some supplementary configurations to control the generation and loading of the bitstream file. By default, the MCC generates source code that loads the synthesized bitstream into the CLB registers and enables the module at start-up during the system initialization step. This is counter-intuitive in the context of multiple configurations because the user may want to load a specific configuration at start-up instead of the last generated one (if its default labels weren’t changed) and enable the CLB manually. This behavior may be turned off by disabling the *Load CLB Bitstream After Reset* and *Enable CLB* options in the CLB Module.
70+
The CLB Module in the MCC also features some supplementary configurations to control the generation and loading of the bitstream file. By default, the MCC generates source code that loads the synthesized bitstream into the CLB registers and enables the module at start-up during the system initialization step. This is counter-intuitive in the context of multiple configurations because the user may want to load a specific configuration at start-up instead of the last generated one (if its default labels weren’t changed) and enable the CLB manually. This behavior may be turned off by disabling the _Load CLB Bitstream After Reset_ and _Enable CLB_ options in the CLB Module.
7271

7372
<picture>
74-
<img alt="Shows an MPLAB® Code Configurator (MCC) Configuration for the CLB1 module with two options highlighted" src="images/mcc/clb1-highlight.png" width="600">
73+
<img alt="Shows an MPLAB Code Configurator (MCC) Configuration for the CLB1 module with two options highlighted" src="images/mcc/clb1-highlight.png" width="600">
7574
</picture>
7675

77-
The other important and useful configuration is the possibility of setting the starting address in Program Flash Memory where the bitstream would reside. This behavior can be turned on by enabling the *Configurable Bitstream Address* option in the CLB Module and inputing the desired value in the now available field, as long as its within the displayed constraints. Additional directives and Program Section flags are generated in order to have the bitstream values laid out in memory at the specified address. The generated preprocessor macro (`CLB_CONFIG_ADDRESS`) may also be renamed along with the other labels to maintain consistency by using the same naming scheme, but this is not mandatory since the define is local to every assembly file. Thus, the configuration for a fixed address can be enabled or disabled at will for each configuration, in case a predefined memory address is needed or not.
76+
The other important and useful configuration is the possibility of setting the starting address in Program Flash Memory where the bitstream would reside. This behavior can be turned on by enabling the _Configurable Bitstream Address_ option in the CLB Module and inputing the desired value in the now available field, as long as its within the displayed constraints. Additional directives and Program Section flags are generated in order to have the bitstream values laid out in memory at the specified address. The generated preprocessor macro (`CLB_CONFIG_ADDRESS`) may also be renamed along with the other labels to maintain consistency by using the same naming scheme, but this is not mandatory since the define is local to every assembly file. Thus, the configuration for a fixed address can be enabled or disabled at will for each configuration, in case a predefined memory address is needed or not.
7877

7978
### Software Limitations
8079

@@ -90,7 +89,7 @@ void ChangeConfiguration(uint16_t const startAddress)
9089
CLB1_Disable();
9190
CLB1_Configure(startAddress);
9291
CLB1_Enable();
93-
92+
9493
return;
9594
}
9695
```
@@ -113,7 +112,7 @@ void InitializeConfigurations(void)
113112
{
114113
configurations[0] = (uint16_t) &start_clb_config;
115114
configurations[1] = (uint16_t) &start_clb_config_alt;
116-
115+
117116
return;
118117
}
119118
```
@@ -122,11 +121,11 @@ void InitializeConfigurations(void)
122121
void SetCurrentConfiguration(void)
123122
{
124123
static uint8_t currentConfigIdx = 0;
125-
124+
126125
ChangeConfiguration(configurations[currentConfigIdx]);
127-
126+
128127
currentConfigIdx = (currentConfigIdx + 1) % NUMBER_OF_CONFIGS;
129-
128+
130129
return;
131130
}
132131
```
@@ -139,10 +138,10 @@ void SetCurrentConfiguration(void)
139138
- Clock Divider: 1
140139

141140
<picture>
142-
<img alt="Shows an MPLAB® Code Configurator (MCC) Configuration for the System Clock" src="images/mcc/clock.png" width="600">
141+
<img alt="Shows an MPLAB Code Configurator (MCC) Configuration for the System Clock" src="images/mcc/clock.png" width="600">
143142
</picture>
144143

145-
***
144+
---
146145

147146
- **Configuration Bits**
148147
- External Oscillator Mode Selection: Oscillator not enabled
@@ -152,10 +151,10 @@ void SetCurrentConfiguration(void)
152151
- Default values for the rest of the bits
153152

154153
<picture>
155-
<img alt="Shows an MPLAB® Code Configurator (MCC) Configuration for the Configuration Bits" src="images/mcc/bits.png" width="600">
154+
<img alt="Shows an MPLAB Code Configurator (MCC) Configuration for the Configuration Bits" src="images/mcc/bits.png" width="600">
156155
</picture>
157156

158-
***
157+
---
159158

160159
- **CLB1**
161160
- Disabled
@@ -165,21 +164,21 @@ void SetCurrentConfiguration(void)
165164
- Load CLB Bitstream after Reset: Disabled
166165

167166
<picture>
168-
<img alt="Shows an MPLAB® Code Configurator (MCC) Configuration for the CLB1 module" src="images/mcc/clb1.png" width="600">
167+
<img alt="Shows an MPLAB Code Configurator (MCC) Configuration for the CLB1 module" src="images/mcc/clb1.png" width="600">
169168
</picture>
170169

171-
***
170+
---
172171

173172
- **GPIO**
174173
- RA5 (`OUTPUT`) - Digital Output (CLBPPSOUT0)
175174
- RC3 (`BUTTON`) - Digital Input with Pullup Enabled (GPIO)
176175

177176
<picture>
178-
<img alt="Shows an MPLAB® Code Configurator (MCC) Configuration for the GPIO module." src="images/mcc/gpio.png" width="600">
177+
<img alt="Shows an MPLAB Code Configurator (MCC) Configuration for the GPIO module." src="images/mcc/gpio.png" width="600">
179178
</picture>
180179

181180
<picture>
182-
<img alt="Shows an MPLAB® Code Configurator (MCC) Configuration for the pin grid." src="images/mcc/grid.png" width="600">
181+
<img alt="Shows an MPLAB Code Configurator (MCC) Configuration for the pin grid." src="images/mcc/grid.png" width="600">
183182
</picture>
184183

185184
## Demo
@@ -210,29 +209,29 @@ This chapter shows how to use the MPLAB X IDE to program a PIC® device with an
210209

211210
3. Set the ExampleProject project as main project.
212211

213-
Right click the project in the **Projects** tab and click Set as Main Project.
212+
Right click the project in the **Projects** tab and click Set as Main Project.
214213

215-
![Set as Main Project](images/main-project.png)
214+
![Set as Main Project](images/main-project.png)
216215

217216
4. Clean and build the ExampleProject project.
218217

219-
Right click on the ExampleProject project and select Clean and Build.
218+
Right click on the ExampleProject project and select Clean and Build.
220219

221-
![Clean and Build](images/clean-and-build.png)
220+
![Clean and Build](images/clean-and-build.png)
222221

223222
5. Select the PIC Curiosity Nano in the Connected Hardware Tool section of the project settings:
224223

225-
- Right click on the project and click Properties
226-
- Click on the arrow under the Connected Hardware Tool
227-
- Select the PIC Curiosity Nano, click **Apply** and then click **OK**:
224+
- Right click on the project and click Properties
225+
- Click on the arrow under the Connected Hardware Tool
226+
- Select the PIC Curiosity Nano, click **Apply** and then click **OK**:
228227

229-
![Select the PIC Curiosity Nano](images/device.png)
228+
![Select the PIC Curiosity Nano](images/device.png)
230229

231230
6. Program the project to the board.
232231

233-
Right click the project and click Make and Program Device.
232+
Right click the project and click Make and Program Device.
234233

235-
![Make and Program Device](images/make-and-program.png)
234+
![Make and Program Device](images/make-and-program.png)
236235

237236
## Contents
238237

assets/design.clb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"type":"Microchip CLB Synthesizer Design","version":"1.0","name":"design","projectId":"ba169e1d-89ec-46a6-9de6-871a15b7f491","creationDate":"2023-10-09T11:51:23.746Z","backendversion":"23.12.1-4","device":"PIC16F13145","clockDivider":4,"schematics":[{"id":"e07450dd-53af-4f30-9cdf-9ef9385a9616","data":{"class":"GraphLinksModel","linkKeyProperty":"key","linkFromPortIdProperty":"fromPort","linkToPortIdProperty":"toPort","nodeDataArray":[{"key":"outputport","category":"outputport","portname":"PPS_OUT0","size":"130 20","loc":"290 20","inputmodifier":"synchronized","angle":90,"flipX":false},{"key":"dff","category":"dff","loc":"230 -50"},{"category":"not","loc":"340 -70","key":4}],"linkDataArray":[{"from":4,"to":"dff","fromPort":"OUT","toPort":"D","key":-3,"points":[381,-70,391,-70,388,-70,388,-70,396,-70,396,-108,172,-108,172,-70,170,-70,180,-70]},{"from":"dff","to":4,"fromPort":"OUT","toPort":"IN1","key":-2,"points":[280,-70,290,-70,290.5,-70,290.5,-70,291,-70,301,-70]},{"from":"dff","to":"outputport","fromPort":"OUT","toPort":"IN","key":-4,"points":[280,-70,290,-70,290,-70,290,-55,290,-55,290,-45]}]}}],"hdls":[],"mnmap":[{"name":"Get Started","id":"af2f626b-f424-4b9f-a254-85537bd18f15","type":3},{"name":"main","id":"e07450dd-53af-4f30-9cdf-9ef9385a9616","type":0}],"entryFile":"main"}
1+
{"type":"Microchip CLB Synthesizer Design","version":"1.0","name":"New Design","projectId":"ba169e1d-89ec-46a6-9de6-871a15b7f491","creationDate":"2023-10-09T11:51:23.746Z","backendversion":"24.2.1-4","device":"PIC16F13145","clockDivider":4,"schematics":[{"id":"e07450dd-53af-4f30-9cdf-9ef9385a9616","data":{"class":"GraphLinksModel","linkKeyProperty":"key","linkFromPortIdProperty":"fromPort","linkToPortIdProperty":"toPort","nodeDataArray":[{"key":"outputport","category":"outputport","portname":"PPS_OUT0","size":"130 20","loc":"290 20","inputmodifier":"synchronized","angle":90,"flipX":false},{"key":"dff","category":"dff","loc":"230 -50"},{"category":"not","loc":"340 -70","key":4}],"linkDataArray":[{"from":4,"to":"dff","fromPort":"OUT","toPort":"D","key":-3,"points":[381,-70,391,-70,388,-70,388,-70,396,-70,396,-108,172,-108,172,-70,170,-70,180,-70]},{"from":"dff","to":4,"fromPort":"OUT","toPort":"IN1","key":-2,"points":[280,-70,290,-70,290.5,-70,290.5,-70,291,-70,301,-70]},{"from":"dff","to":"outputport","fromPort":"OUT","toPort":"IN","key":-4,"points":[280,-70,290,-70,290,-70,290,-55,290,-55,290,-45]}]}}],"hdls":[],"mnmap":[{"name":"Get Started","id":"af2f626b-f424-4b9f-a254-85537bd18f15","type":3},{"name":"main","id":"e07450dd-53af-4f30-9cdf-9ef9385a9616","type":0}],"entryFile":"main"}

0 commit comments

Comments
 (0)