Skip to content

Commit 91571b7

Browse files
committed
CM0 CM0+: interrupts disabled beween xTaskCreate() and vTaskStartScheduler()
On Cortex-M0 and Cortex-M0+, all IT are disabled between xTaskCreate() and vTaskStartScheduler(). So it is not possible to use IT inbetween, like Serial.print() ... This is the reason why, in example "frLiyLayland", between xTaskCreate() and vTaskStartScheduler(), we use direct printf(), which will access directly USART without interrupt Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
1 parent 3d96020 commit 91571b7

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ CMSIS-RTOSv2.
4949

5050
* MPU: not supported.
5151
* No CMSIS-RTOSv2 support provided. It is provided as example.
52+
* On Cortex-M0 and Cortex-M0+, all IT are disabled between xTaskCreate() and vTaskStartScheduler().
53+
So it is not possible to use IT inbetween, like Serial.print() ...
54+
This is the reason why, in example "frLiyLayland", between xTaskCreate() and vTaskStartScheduler(),
55+
we use direct printf(), which will access directly USART without interrupt
5256

5357
## Files & Configuration
5458

@@ -109,8 +113,8 @@ CMSIS-RTOSv2.
109113
### STM32FreeRTOS v10.3.1
110114
| Board | AnalogRead_DigitalRead | frBlinkPrint | frLiuLayland | frBlink (CMSIS-RTOSv2) | Blinky (CMSIS-RTOSv2) |
111115
| --- | :---: | :---: | :---: | :---: | :---: |
112-
| [Nucleo F091RC (Cortex-M0)](http://www.st.com/en/evaluation-tools/nucleo-f091rc.html) | PASSED | PASSED | FAILED | PASSED | PASSED |
113-
| [Nucleo G071RB (Cortex-M0+)](http://www.st.com/en/evaluation-tools/nucleo-g071rb.html) | PASSED | PASSED | FAILED | PASSED | PASSED |
116+
| [Nucleo F091RC (Cortex-M0)](http://www.st.com/en/evaluation-tools/nucleo-f091rc.html) | PASSED | PASSED | PASSED | PASSED | PASSED |
117+
| [Nucleo G071RB (Cortex-M0+)](http://www.st.com/en/evaluation-tools/nucleo-g071rb.html) | PASSED | PASSED | PASSED | PASSED | PASSED |
114118
| [Nucleo F103RB (Cortex-M3)](http://www.st.com/en/evaluation-tools/nucleo-f103rb.html) | PASSED | PASSED | PASSED | PASSED | PASSED |
115119
| [Nucleo L476RG (Cortex-M4)](http://www.st.com/en/evaluation-tools/nucleo-l476rg.html) | PASSED | PASSED | PASSED | PASSED | PASSED |
116120
| [Nucleo H743ZI (Cortex-M7)](https://www.st.com/en/evaluation-tools/nucleo-h743zi.html) | PASSED | PASSED | PASSED | PASSED | PASSED |

examples/frLiuLayland/frLiuLayland.ino

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,22 @@ void calibrate() {
6868
}
6969
//------------------------------------------------------------------------------
7070
// print helpers
71+
// On Cortex-M0 and Cortex-M0+, all IT are disabled between xTaskCreate() and vTaskStartScheduler().
72+
// So it is not possible to use IT inbetween, like Serial.print() ...
73+
// This is the reason why, in example "frLiyLayland", between xTaskCreate() and vTaskStartScheduler(),
74+
// we use direct printf(), which will access directly USART without interrupt
7175
void printTask(task_t* task) {
72-
Serial.print(task->period);
73-
Serial.write(',');
74-
Serial.print(task->cpu);
75-
Serial.write(',');
76-
Serial.println(task->priority);
76+
printf("%u, ", task->period);
77+
printf("%u, ", task->cpu);
78+
printf("%u\r\n", task->priority);
7779
}
7880
void done(const char* msg, task_t* task, TickType_t now) {
7981
vTaskSuspendAll();
8082
Serial.println(msg);
8183
Serial.print("Tick: ");
8284
Serial.println(now);
8385
Serial.print("Task: ");
86+
Serial.flush();
8487
printTask(task);
8588
while(1);
8689
}
@@ -152,21 +155,22 @@ void setup() {
152155
Serial.println(micros() -t);
153156
Serial.println("Starting tasks - period and CPU in ticks");
154157
Serial.println("Period,CPU,Priority");
158+
Serial.flush();
155159
for (int i = 0; i < n; i++) {
156160
printTask(&tasks[i]);
157161
cpuUse += tasks[i].cpu/(float)tasks[i].period;
158162

159163
s = xTaskCreate(task, NULL, 200, (void*)&tasks[i], tasks[i].priority, NULL);
160164
if (s != pdPASS) {
161-
Serial.println("task create failed");
165+
printf("task create failed\n");
162166
while(1);
163167
}
164168
}
165-
Serial.print("CPU use %: ");
166-
Serial.println(cpuUse*100);
167-
Serial.print("Liu and Layland bound %: ");
168-
Serial.println(LiuLayland[n - 1]);
169169

170+
char CPU[10];
171+
char bound[10];
172+
printf("CPU use %%: %s\r\n", dtostrf(cpuUse*100, 6, 2, CPU));
173+
printf("Liu and Layland bound %%: %s\r\n", dtostrf(LiuLayland[n - 1], 6, 2, bound));
170174
// start tasks
171175
vTaskStartScheduler();
172176
Serial.println("Scheduler failed");

0 commit comments

Comments
 (0)