Skip to content

Commit 4f1c112

Browse files
committed
MPAE-18219 implemented review comments from MCU8_TEJ-1486
1 parent 56ea709 commit 4f1c112

File tree

9 files changed

+74
-47
lines changed

9 files changed

+74
-47
lines changed
-672 Bytes
Binary file not shown.

README.md

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88

99
# MCC Melody ADC Data Streamer Example - Callbacks Implementation (PIC18F57Q43)
1010

11-
The [ADC Data Streamer example](https://onlinedocs.microchip.com/v2/keyword-lookup?keyword=MCC.MELODY.EXAMPLES.RUNNING.ADCC.DATA.STREAMER&version=latest&redirect=true "Analog-to-Digital Conversion (ADC) Data Streamer example"), of the MCC Melody ADCC Example Component, is used in the Callbacks Implementation. Displays ADCC samples visualized with the Data Streamer. An ADC conversion is taken every 100 ms on the selected analog channel, also toggling a LED and Debug GPIO.
11+
The [ADC Data Streamer example](https://onlinedocs.microchip.com/v2/keyword-lookup?keyword=MCC.MELODY.EXAMPLES.RUNNING.ADCC.DATA.STREAMER&version=latest&redirect=true "Analog-to-Digital Conversion (ADC) Data Streamer example"), of the MCC Melody ADCC Example Component, is used in the Callbacks implementation and displays ADCC samples visualized with the Data Streamer. An Analog-to-Digital Conversion measurement is taken every 100 ms on the selected analog channel, also toggling an LED and Debug GPIO.
1212

1313
## MCC Melody Example Components
1414
Example Components are a tight integration of learning material directly into MCC. This allows users to conveniently place configuration instructions side-by-side to the components they are configuring. For more information, refer to the [MCC Melody Example Components Introduction](https://onlinedocs.microchip.com/v2/keyword-lookup?keyword=MCC.MELODY.EXAMPLES&version=latest&redirect=true).
1515

16-
**Note:** The image below shows the ADCC Example Component, as it would be moving to the ADCC Data Streamer (Callbacks Implementation), having implemented the ADCC Basic Printf (Callbacks Implementation). In this case a diff between the two examples is shown.
16+
**Note:** The image below shows the ADCC Example Component, as it would be moving to the ADCC Data Streamer, having implemented the ADCC Basic Printf, both of which are part of the Callbacks implementation. In this case. a diff between the two examples is shown.
1717

1818
![MCC Melody Example Components](images/ADCCDataStreamer_CallbacksFromBasiPrintfCallbacks-Intro.png)
1919

@@ -48,7 +48,7 @@ All instructions required to recreate this example are listed below, under Confi
4848

4949
![TIMER Toggle LED, Callbacks Implementation](images/ADCC_DataStreamer_Callbacks-ConfigComplete.png)
5050

51-
Once you have loaded the project in MPLAB X IDE, you will also be able to find more information from Tooltips and links next to the instructions
51+
Once the project is loaded in MPLAB X IDE, the user will be able to find more information from Tooltips and links next to the instructions
5252
[![Tooltip and link](images/Icon-info-circle-fill.png "Find the Tx pin from your schematic and set it in Pin Grid View.")](https://onlinedocs.microchip.com/v2/keyword-lookup?keyword=MCC.MELODY.CONFIGHELP.UART.CNANO&version=latest&redirect=true).
5353

5454

@@ -57,44 +57,42 @@ Once you have loaded the project in MPLAB X IDE, you will also be able to find m
5757

5858
## Operation
5959
The image below shows the [ADCC Basic Printf example](https://onlinedocs.microchip.com/v2/keyword-lookup?keyword=MCC.MELODY.EXAMPLES.RUNNING.ADCC.PRINTF&version=latest&redirect=true
60-
) running, using the MPLAB Data Visualizer.
60+
) running, using the MPLAB Data Visualizer.
61+
62+
![Running the ADCC Basic Printf Example](images/Running_the_ADCC_Data_Streamer_Example.png)
63+
64+
## Data Visualizer Configuration
6165

6266
1) Click the ![Data Visualizer icon](images/Icon-MPLAB-DataVisualizer_1cm.png) icon to open the MPLAB Data Visualizer.
63-
2) Under the *Variable Streamers* tab (on the left hand side), click the ![Import ds file](images/button-import-ds-file.png "Import DS file.") button, to import a *.ds* file.
64-
3) From your project root, navigate into *mmc_generated_files/data_streamer/* directory.
65-
4) Click on the *data_streamer.ds* file to select it.
66-
5) Then click the ![open button](images/button-open.png) button, to load the ds file.
67+
2) Under the **Variable Streamers** tab (on the left-hand side), click the ![Import ds file](images/button-import-ds-file.png "Import DS file.") button, to import a `.ds` file.
68+
3) From your project root, navigate into `mcc_generated_files/data_streamer/` directory.
69+
4) Click the `data_streamer.ds` file to select it.
70+
5) Then click the ![open button](images/button-open.png) button to load the ds file.
6771

68-
![Loading the ds file](images/Running the ADCC Data Streamer Example)
72+
![Loading the ds file](images/RunningDataStreamerEx-Open_ds_file_12cm.png)
6973

70-
You should see a *data_streamer Properties* window, showing the *adcResult* and *adcSampleCount* variables loaded.
74+
The data_streamer Properties window will open up, displaying the loaded adcResult and adcSampleCount variables.
7175

72-
1) Click the ![save button](images/button-save.png) button, to load this data streamer configuration.
76+
1) Click the ![save button](images/button-save.png) button to load this data streamer configuration.
7377

7478
![ds file loaded](images/ds_file_loaded_1_12cm.png)
7579

76-
1) Click on the ![no source button](images/button-no-source.png) button.
77-
2) Select your board from those available.
80+
2) Click the ![no source button](images/button-no-source.png) button.
81+
3) Select your board from those available.
7882

79-
**Note:** If your board is not recognised by the MPLAB Data Visualizer, got to the Device Manager (Windows), to determine the COMx number.
83+
**Note:** If your board is not recognised by the MPLAB Data Visualizer, go to the Device Manager (Windows) to determine the COMx number.
8084

81-
3) Click on the ![settings gear icon](images/Icon-DataVisualizer-SettingsGear.png) icon, to bring up the COMx Settings.
82-
4) Set the baud rate to 115200, then click out of the window to close the settings.
83-
5) Click the ![Time Plot icon](images/Icon-DataVisualizer_TimePlot.png) icon, to plot all variables.
85+
4) Click the ![settings gear icon](images/Icon-DataVisualizer-SettingsGear.png) icon to bring up the COMx Settings.
86+
5) Set the baud rate to 115200, then click out of the window to close the settings.
87+
6) Click the ![Time Plot icon](images/Icon-DataVisualizer_TimePlot.png) icon to plot all variables.
8488

8589
![Data Streamer Config](images/DataStreamerConfig_25cm.png)
8690

87-
1) Click on the *Connections* button.
88-
2) Under Debug GPIO, click the ![Add to time plot icon](images/Icon-DataVisualizer_TimePlot.png "Display as raw data on time plot.") icon, to add to the time plot.
91+
1) Click the **Connections** button.
92+
2) Under Debug GPIO, click the ![Add to time plot icon](images/Icon-DataVisualizer_TimePlot.png "Display as raw data on time plot.") icon to add to the time plot.
8993

9094
![Debug I/O Time Plot](images/DebugIO_TimePlot_8cm.png)
9195

92-
If all is correct, when changing the pot meter value, you should see similar results to the below image.
93-
94-
![Running the ADCC Basic Printf Example](images/Running_the_ADCC_Data_Streamer_Example.png)
95-
96-
97-
## Summary
9896
For more example components, open the stand-alone Content Manager ![CM_icon](images/Icon-MPLAB-CM24.png) in MCC.
9997

10098
![Standalone_CM](images/MCC_ContentManager_Examples_18cm.png)

pic18f57q43-adcc-data-streamer-callbacks-mcc.X/main.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@
3838
static void ADCC_ConversionDone_Callback(void);
3939
static void Timer_Callback_100ms(void);
4040

41-
static const struct TMR_INTERFACE *Timer = &Timer2; // TODO: Replace TimerX with name of const struct TMR_INTERFACE, from MCC Generated Files > timer > tmrx.c
41+
static const struct TMR_INTERFACE *Timer_dsFrame = &Timer_ds; // TODO: Replace TimerX with name of const struct TMR_INTERFACE, from MCC Generated Files > timer > tmrx.c
42+
static const struct TMR_INTERFACE *Timer_printfADC = &Timer_printf;
43+
4244
static volatile bool sendFrame = false;
45+
static volatile bool printResult = false;
4346

4447
void ADCC_ConversionDone_Callback(void)
4548
{
@@ -56,14 +59,22 @@ void Timer_Callback_100ms(void)
5659
ADCC_StartConversion(channel_ANA7); // TODO: Replace x with the ADCC Channel you selected in Pin Grid View
5760
}
5861

62+
void Timer_Callback_1s(void)
63+
{
64+
printResult = true;
65+
}
66+
67+
5968
int main(void)
6069
{
6170
SYSTEM_Initialize();
6271

6372
DataStreamer.adcSampleCount = 0;
6473
DataStreamer.adcResult = 0;
6574
ADCC_SetADIInterruptHandler(ADCC_ConversionDone_Callback);
66-
Timer->TimeoutCallbackRegister(Timer_Callback_100ms);
75+
76+
Timer_dsFrame->TimeoutCallbackRegister(Timer_Callback_100ms);
77+
Timer_printfADC->TimeoutCallbackRegister(Timer_Callback_1s);
6778

6879
INTERRUPT_GlobalInterruptEnable();
6980

@@ -74,5 +85,11 @@ int main(void)
7485
WriteFrame();
7586
sendFrame = false;
7687
}
88+
if (printResult)
89+
{
90+
(void) printf("The ADC Result is: %d\r\n", DataStreamer.adcResult);
91+
IO_Debug_SetHigh();
92+
printResult = false;
93+
}
7794
}
7895
}

pic18f57q43-adcc-data-streamer-callbacks-mcc.X/mcc-manifest-autosave.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
manifest_file_version: 1.0.0
44
project: pic18f57q43-adcc-data-streamer-callbacks-mcc
5-
creation_date: 2024-08-07T17:23:42.438+02:00[Europe/Paris]
5+
creation_date: 2024-09-05T14:43:22.931+02:00[Europe/Paris]
66
operating_system: Windows 10
77
mcc_mode: IDE
88
mcc_mode_version: v6.20
99
device_name: PIC18F57Q43
1010
compiler: XC8 2.46
1111
mcc_version: 5.5.1
1212
mcc_core_version: 5.7.1
13-
content_manager_version: 5.0.1-e
13+
content_manager_version: 5.0.1
1414
is_mcc_offline: false
1515
is_using_prerelease_versions: false
1616
mcc_content_registries: https://registry.npmjs.org/

pic18f57q43-adcc-data-streamer-callbacks-mcc.X/mcc-manifest-generated-success.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
manifest_file_version: 1.0.0
44
project: pic18f57q43-adcc-data-streamer-callbacks-mcc
5-
creation_date: 2024-08-07T17:23:42.405+02:00[Europe/Paris]
5+
creation_date: 2024-09-05T14:43:22.901+02:00[Europe/Paris]
66
operating_system: Windows 10
77
mcc_mode: IDE
88
mcc_mode_version: v6.20
99
device_name: PIC18F57Q43
1010
compiler: XC8 2.46
1111
mcc_version: 5.5.1
1212
mcc_core_version: 5.7.1
13-
content_manager_version: 5.0.1-e
13+
content_manager_version: 5.0.1
1414
is_mcc_offline: false
1515
is_using_prerelease_versions: false
1616
mcc_content_registries: https://registry.npmjs.org/

pic18f57q43-adcc-data-streamer-callbacks-mcc.X/mcc_generated_files/timer/src/tmr2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#include <xc.h>
3939
#include "../tmr2.h"
4040

41-
const struct TMR_INTERFACE Timer2 = {
41+
const struct TMR_INTERFACE Timer_ds = {
4242
.Initialize = TMR2_Initialize,
4343
.Start = TMR2_Start,
4444
.Stop = TMR2_Stop,

pic18f57q43-adcc-data-streamer-callbacks-mcc.X/mcc_generated_files/timer/tmr2.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,62 +43,62 @@
4343
* @ingroup tmr2
4444
* @brief Defines the Custom Name for the \ref TMR2_Initialize API
4545
*/
46-
#define Timer2_Initialize TMR2_Initialize
46+
#define Timer_ds_Initialize TMR2_Initialize
4747

4848
/**
4949
* @ingroup tmr2
5050
* @brief Defines the Custom Name for the \ref TMR2_ModeSet API
5151
*/
52-
#define Timer2_ModeSet TMR2_ModeSet
52+
#define Timer_ds_ModeSet TMR2_ModeSet
5353

5454
/**
5555
* @ingroup tmr2
5656
* @brief Defines the Custom Name for the \ref TMR2_ExtResetSourceSet API
5757
*/
58-
#define Timer2_ExtResetSourceSet TMR2_ExtResetSourceSet
58+
#define Timer_ds_ExtResetSourceSet TMR2_ExtResetSourceSet
5959

6060
/**
6161
* @ingroup tmr2
6262
* @brief Defines the Custom Name for the \ref TMR2_Start API
6363
*/
64-
#define Timer2_Start TMR2_Start
64+
#define Timer_ds_Start TMR2_Start
6565

6666
/**
6767
* @ingroup tmr2
6868
* @brief Defines the Custom Name for the \ref TMR2_Stop API
6969
*/
70-
#define Timer2_Stop TMR2_Stop
70+
#define Timer_ds_Stop TMR2_Stop
7171

7272
/**
7373
* @ingroup tmr2
7474
* @brief Defines the Custom Name for the \ref TMR2_Read API
7575
*/
76-
#define Timer2_Read TMR2_Read
76+
#define Timer_ds_Read TMR2_Read
7777

7878
/**
7979
* @ingroup tmr2
8080
* @brief Defines the Custom Name for the \ref TMR2_Write API
8181
*/
82-
#define Timer2_Write TMR2_Write
82+
#define Timer_ds_Write TMR2_Write
8383

8484
/**
8585
* @ingroup tmr2
8686
* @brief Defines the Custom Name for the \ref TMR2_PeriodCountSet API
8787
*/
88-
#define Timer2_PeriodCountSet TMR2_PeriodCountSet
88+
#define Timer_ds_PeriodCountSet TMR2_PeriodCountSet
8989

9090
/**
9191
* @ingroup tmr2
9292
* @brief Defines the Custom Name for the \ref TMR2_OverflowCallbackRegister API
9393
*/
94-
#define Timer2_OverflowCallbackRegister TMR2_OverflowCallbackRegister
94+
#define Timer_ds_OverflowCallbackRegister TMR2_OverflowCallbackRegister
9595

9696
/**
9797
@ingroup tmr2
9898
@struct TMR_INTERFACE
9999
@brief This is an instance of TMR_INTERFACE for TMR2 module.
100100
*/
101-
extern const struct TMR_INTERFACE Timer2;
101+
extern const struct TMR_INTERFACE Timer_ds;
102102

103103
/**
104104
* @ingroup tmr2

pic18f57q43-adcc-data-streamer-callbacks-mcc.X/mcc_generated_files/uart/src/uart1.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,18 @@ void UART1_TransmitISR(void)
425425
}
426426
}
427427

428+
int getch(void)
429+
{
430+
while(!(UART1_IsRxReady()));
431+
return UART1_Read();
432+
}
433+
434+
void putch(char txData)
435+
{
436+
while(!(UART1_IsTxReady()));
437+
return UART1_Write(txData);
438+
}
439+
428440

429441

430442

pic18f57q43-adcc-data-streamer-callbacks-mcc.X/pic18f57q43-adcc-data-streamer-callbacks-mcc.mc3

Lines changed: 5 additions & 5 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)