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: content/hardware/04.pro/boards/portenta-h7/tutorials/dual-core-processing/content.md
+15-15Lines changed: 15 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ The Portenta H7 is equipped with a processor that has two processing units calle
25
25
## Goals
26
26
27
27
- How to upload and run applications on Portenta's M7 and M4 cores.
28
-
-About the characteristics of the M7 and the M4 cores.
28
+
-Learn about the characteristics of the M7 and the M4 cores.
29
29
- How to force boot the M4 core through the M7 core and why that is necessary.
30
30
- Controlling the colors of the built-in RGB LED.
31
31
@@ -36,30 +36,30 @@ The Portenta H7 is equipped with a processor that has two processing units calle
36
36
- Arduino IDE 1.8.10+ or Arduino Pro IDE 0.0.4+
37
37
38
38
## Cortex® M7 & M4
39
-
Processor cores are individual processing units within the board's main processing unit (don't confuse a processor core with an [Arduino core](https://www.arduino.cc/en/guide/cores)). These cores are responsible for the executing instructions at a particular clock speed. The on-board Arm Cortex processor comes with two cores (Cortex® M7 and M4), with slightly different architectures and clock speeds. The M7 runs at 480 MHz and the architecture is designed to separate Instruction and Data buses to optimize CPU latency. The M4 runs at 240 MHz and the architecture supports the ART™ accelerator (a block that speeds up instruction fetching accesses of the Cortex-M4 core to the D1-domain internal memories). The higher clock rate of the M7 makes it suitable to handle complex processing tasks such as data storage, debugging or handling input/output peripherals at a higher efficiency compared to the M4. The dual core processor of the Portenta H7 sets it apart from other single core Arduino boards by allowing true multitasking, faster data processing capabilities, enhanced processing power and application partitioning.
39
+
Processor cores are individual processing units within the board's main processing unit (do not confuse a processor core with an [Arduino core](https://www.arduino.cc/en/guide/cores)). These cores are responsible for executing instructions at a particular clock speed. The on-board Arm Cortex processor comes with two cores (Cortex® M7 and M4), with slightly different architectures and clock speeds. The M7 runs at 480 MHz and the architecture is designed to separate Instruction and Data buses to optimize CPU latency. The M4 runs at 240 MHz and the architecture supports the ART™ accelerator (a block that speeds up instruction fetching accesses of the Cortex-M4 core to the D1-domain internal memories). The higher clock rate of the M7 makes it suitable to handle complex processing tasks such as data storage, debugging or handling input/output peripherals at a higher efficiency compared to the M4. The dual core processor of the Portenta H7 sets it apart from other single core Arduino boards, by allowing true multitasking, faster data processing capabilities, enhanced processing power and application partitioning.
40
40
41
41

42
42
43
43
## Instructions
44
44
45
45
### Accessing the M7 and M4 Core
46
-
To best illustrate the idea of dual core processing, you will be running two separate sketch files. One on each of the cores which blinks the RGB LED in a different color. The **BlinkRedLed_M7.ino** sketch will set the built-in RGB LED on the board to red and blink it with a delay of 500 ms. The **BlinkGreenLed_M4.ino** sketch will access the green LED in the RGB led and blink it with a delay of 200 ms. Both the cores will be executing the corresponding sketch file simultaneously and as a result both the green and red LED blink, however, at different intervals.
46
+
To best illustrate the idea of dual core processing, you will be running two separate sketch files. One on each of the cores which blinks the RGB LED in a different color. The **BlinkRedLed_M7.ino** sketch will set the built-in RGB LED on the board to red and blink it with a delay of 500 ms. The **BlinkGreenLed_M4.ino** sketch will access the green LED in the RGB led and blink it with a delay of 200 ms. Both the cores will be executing the corresponding sketch file simultaneously and as a result both the green and red LED blink, however, at different intervals.
47
47
48
48

49
49
50
50
### 1. The Basic Setup
51
-
Begin by plugging-in your Portenta board to your computer using an appropriate USB-C cable and have the Arduino IDE or the Arduino Pro IDE open. If this is your first time running Arduino sketch files on the board, we suggest you check out how to [Setting Up Portenta H7 For Arduino](setting-up-portenta) before you proceed.
51
+
Begin by plugging-in your Portenta board to your computer using an appropriate USB-C cable and have the Arduino IDE open. If this is your first time running Arduino sketch files on the board, we suggest you check out how to [Setting Up Portenta H7 For Arduino](https://docs.arduino.cc/tutorials/portenta-h7/setting-up-portenta) before you proceed.
52
52
53
53

54
54
55
-
**Note:** You can access the examples from the tutorials library once it's installed: **Examples > Arduino_Pro_Tutorials > Dual Core Processing**
55
+
**Note:** You can access the examples from the tutorials library once it is installed: **Examples > Arduino_Pro_Tutorials > Dual Core Processing**
56
56
57
57
### 2. Setting the LED Color
58
58
In the previous tutorial you learned how to access the built-in RGB LED through the macro definition LED_BUILTIN. You can also control the distinct Red, Green and Blue LED separately through the LEDR, LEDG and LEDB macro definition respectively.
59
59
60
60
Please note that, opposed to other Arduino boards, on the Portenta H7 the built-in RGB led pins need to be pulled to ground to make the LED light up. This means that a voltage level of LOW will turn the LED on, a voltage level of HIGH will turn it off.
61
61
62
-
The following sketch blinks the red LED at an interval of 200ms controlled by the M7 core.Save your sketch as **BlinkRedLed_M7** and compile your sketch file.
62
+
The following sketch blinks the red LED at an interval of 200ms controlled by the M7 core.Save your sketch as **BlinkRedLed_M7** and compile your sketch file.
63
63
64
64
```cpp
65
65
// the setup function runs once when you press reset or power the board
@@ -78,7 +78,7 @@ void loop() {
78
78
```
79
79
80
80
### 3. Upload the Sketch to the M7 Core
81
-
Select the **Arduino Portenta H7 (M7 core)** from the **Board** menu and the port the Portenta is connected to (e.g. /dev/cu.usbmodem141101). Upload the **BlinkRedLed_M7.ino** sketch. Doing so will automatically compile the sketch beforehand. When the sketch is uploaded the RGB LED on the board will start blinking red.
81
+
Select the **Arduino Portenta H7 (M7 core)** from the **Board** menu and the port the Portenta is connected to (e.g. /dev/cu.usbmodem141101). Upload the **BlinkRedLed_M7.ino** sketch. Doing so will automatically compile the sketch beforehand. When the sketch is uploaded, the RGB LED on the board will start blinking red.
82
82
83
83

84
84
@@ -101,10 +101,10 @@ void loop() {
101
101
}
102
102
```
103
103
104
-
If you would upload the sketch to the M4 at this point nothing would change. The reason is that the M4 core doesn't start up by itself. There is one more step required to make the M4 core blink the LED green: Force booting the M4.
104
+
If you would like to upload the sketch to the M4, at this point nothing would change. The reason is that the M4 core does not start up by itself. There is one more step required to make the M4 core blink the LED green: Force booting the M4.
105
105
106
106
### 5. Force Booting the M4 Core
107
-
The bootloader of the H7 boards is configured in such a way that only M7 gets booted automatically. The reason is that for simple use cases the M4 may not be needed and hence be unprogrammed and doesn't need to get powered. One such instance is when the M7 doesn't have the appropriate firmware that automatically handles the initialization of the M4. As a result you need to force boot the M4 so that it can run a sketch. You can do so through the M7 using a special command, `bootM4()` that boots the M4 when the board is powered.
107
+
The bootloader of the H7 boards is configured in such a way that only M7 gets booted automatically. The reason is that for simple use cases the M4 may not be needed, hence be unprogrammed and does not need to get powered. One such instance is when the M7 does not have the appropriate firmware that automatically handles the initialization of the M4. As a result you need to force boot the M4 so that it can run a sketch. You can do so through the M7 using a special command, `bootM4()` that boots the M4 when the board is powered.
108
108
109
109

110
110
@@ -130,16 +130,16 @@ void loop() {
130
130
Once this sketch runs on the M7 core, it boots the M4 core and allows it to run its corresponding sketch.
131
131
132
132
### 6. Uploading to the M4 Core
133
-
The final step is to upload the sketch that we prepared for the M4. Now open **Tools> Boards** from the IDE menu and select **Arduino Portenta H7 (M4 core)** from the boards. Upload the **BlinkGreenLed_M4.ino** to the board. Note that there is no separate serial port listed for the M4 in the port menu as the M7 takes care of the serial communication. The RGB LED blinking in RED currently, starts blinking in green simultaneously at an interval of 500 ms. When the blinking overlaps the mix of red and green light is perceived as yellow.
133
+
The final step is to upload the sketch that you prepared for the M4. Now open **Tools> Boards** from the IDE menu and select **Arduino Portenta H7 (M4 core)** from the boards. Upload the **BlinkGreenLed_M4.ino** to the board. Note that there is no separate serial port listed for the M4 in the port menu as the M7 takes care of the serial communication. The RGB LED blinking in RED currently starts blinking in green simultaneously at an interval of 500 ms. When the blinking overlaps the mix of red and green light is perceived as yellow.
134
134
135
135

136
136
137
137
### Programming Both Cores With Just One Sketch
138
-
So far, we used separate sketch files to program the different cores. We can also combine these two sketch files into one by taking advantage the preprocessor directives '#ifdef'. This way you can program different behaviors for both cores by using the same program.
138
+
So far, you used separate sketch files to program the different cores. You can also combine these two sketch files into one by taking advantage the preprocessor directives '#ifdef'. This way you can program different behaviors for both cores by using the same program.
139
139
140
140
***Programming bigger applications by using this method may increase the difficulty of the program you will need to create.***
141
141
142
-
Let's now to create a new sketch to blink both of LEDs with random sequences, this will allow you to clearly see different behaviors for both of the LEDs using a very simple program.
142
+
Let's now create a new sketch to blink both of LEDs with random sequences, this will allow you to clearly see different behaviors for both of the LEDs using a very simple program.
143
143
144
144
### 1. Programming the M7 Core Set-Up
145
145
Let's start by opening a new sketch and naming it **BlinkBothCores.ino**. Then let's add the following lines of code.
@@ -157,7 +157,7 @@ void setup() {
157
157
#endif
158
158
```
159
159
160
-
The code between `#ifdef CORE_CM7` and `#endif` will only apply for the M7 Core to boot the M4 core allowing it to run its corresponding sketch, that portion of code will also allow the M7 core control the blue LED of the board.
160
+
The code between `#ifdef CORE_CM7` and `#endif` will only apply for the M7 Core to boot the M4 core, allowing it to run its corresponding sketch. That portion of code will also allow the M7 core control the blue LED of the board.
161
161
162
162
### 2. Programming the M4 Core Setup
163
163
Then, as well inside the `setup()` function, you will need to include the following lines to configure properly the green LED in the M4 core.
@@ -169,7 +169,7 @@ Then, as well inside the `setup()` function, you will need to include the follow
169
169
```
170
170
171
171
### 3. Finishing the Setup() Function and Programming the Loop()
172
-
To finish with the `setup()` you will need to initialize the LEDs as outputs.
172
+
To finish with the `setup()`, you will need to initialize the LEDs as outputs.
173
173
174
174
Then in the `loop()` function you will need to include the sequence that blink the LEDs. to do so, add the following portion of code right after the `#endif`.
175
175
@@ -188,7 +188,7 @@ void loop() {
188
188
Now can upload the sketch to both the cores of the Portenta H7 individually. With this sketch, you will be able to control the LED through both the cores (M4 and M7) and you should be able to see the Blue and Green LEDs of the Portenta board blinking with different sequences.
189
189
190
190
## Conclusion
191
-
This tutorial introduces the idea of dual core processing and illustrates the concept by using the M7 and M4 cores to control the different colors of the built-in RGB LED. This simple example only describes how to access the M7 and M4 cores. In the upcoming tutorials you will learn to create applications that leverage the potential of dual core processing to perform more complex tasks.
191
+
This tutorial introduces the idea of dual core processing and illustrates the concept by using the M7 and M4 cores to control the different colors of the built-in RGB LED. This simple example only describes how to access the M7 and M4 cores. In the upcoming tutorials you will learn how to create applications that leverage the potential of dual core processing to perform more complex tasks.
0 commit comments