Skip to content

Commit b5b32db

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 <[email protected]>
1 parent 3d96020 commit b5b32db

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
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: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,14 @@ 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();
@@ -158,15 +160,12 @@ void setup() {
158160

159161
s = xTaskCreate(task, NULL, 200, (void*)&tasks[i], tasks[i].priority, NULL);
160162
if (s != pdPASS) {
161-
Serial.println("task create failed");
163+
printf("task create failed\n");
162164
while(1);
163165
}
164166
}
165-
Serial.print("CPU use %: ");
166-
Serial.println(cpuUse*100);
167-
Serial.print("Liu and Layland bound %: ");
168-
Serial.println(LiuLayland[n - 1]);
169-
167+
printf("CPU use %%: %f\r\n", cpuUse * 100);
168+
printf("Liu and Layland bound %%: %f\r\n", LiuLayland[n - 1]);
170169
// start tasks
171170
vTaskStartScheduler();
172171
Serial.println("Scheduler failed");
@@ -177,4 +176,4 @@ void setup() {
177176
// loop must never block
178177
void loop() {
179178
// not used
180-
}
179+
}

0 commit comments

Comments
 (0)