Skip to content

Commit 3e54ee5

Browse files
Fix typos
1 parent cda7e36 commit 3e54ee5

File tree

1 file changed

+47
-47
lines changed

1 file changed

+47
-47
lines changed

README.md

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ A dedicated performance counter for Cortex-M Systick. It shares the SysTick with
2020
- Easy to port to a different architecture with a porting template
2121

2222
- **Provide Free Services**
23-
- Do **NOT** interfer with existing SysTick based applications
23+
- Do **NOT** interfere with existing SysTick-based applications
2424
- **Support most of the arm compilers**
2525
- Arm Compiler 5 (armcc), Arm Compiler 6 (armclang)
2626
- arm gcc
@@ -30,7 +30,7 @@ A dedicated performance counter for Cortex-M Systick. It shares the SysTick with
3030
- **Drag-and-Drop deployment for Arm Compiler 5 and Arm Compiler 6.**
3131
- **CMSIS-Pack is available**
3232
- **RT-Thread package is avaialble**
33-
- **Time based services**
33+
- **Time-based services**
3434
- `delay_us()` and `delay_ms()` with **64bit return value**.
3535
- Provides Timestamp services via `get_system_ticks()`, `get_system_us` and `get_system_ms()`.
3636
- **Support both RTOS and bare-metal environments**
@@ -39,12 +39,12 @@ A dedicated performance counter for Cortex-M Systick. It shares the SysTick with
3939
- Support stack-overflow detection in RTOS environment via `perfc_check_task_stack_canary_safe()`
4040
- **Utilities for C language enhancement**
4141
- Macros to detect compilers, e.g. `__IS_COMPILER_ARM_COMPILER_6__`, `__IS_COMPILER_LLVM__` etc.
42-
- Macro to create atomicity for specified code block, i.e. `__IRQ_SAFE{...}`
42+
- Macro to create atomicity for a specified code block, i.e. `__IRQ_SAFE{...}`.
4343
- Helper macros for C language extension:
4444
- VB like `with()`
4545
- `foreach()`, dimof(), `CONNECT()`
4646
- C# like `using()`
47-
- simple overload feature of OOPC made out of ANSI-C99, `__PLOOC_VA_NUM_ARGS()`
47+
- simple overload feature of OOPC made out of ANSI-C99, `__PLOOC_VA_NUM_ARGS()`.
4848
- **[new]** add macros for PT
4949
- ...
5050
- A dedicated macro `__perfc_sync_barrier__()` for code barrier.
@@ -53,9 +53,9 @@ A dedicated performance counter for Cortex-M Systick. It shares the SysTick with
5353

5454
## 1. How To Use
5555

56-
### 1.1 Measure CPU cycles for specified code segment
56+
### 1.1 Measure CPU cycles for a specified code segment
5757

58-
You can measure specified code segment with a macro helper `__cycleof__()`, it is a wrapper of `get_system_ticks()`.
58+
You can measure a specified code segment with a macro helper `__cycleof__()`, a wrapper of `get_system_ticks()`.
5959

6060
**Syntax:**
6161

@@ -66,7 +66,7 @@ __cycleof__(<Description String for the target>, [User Code, see ref 1]) {
6666
}
6767
```
6868
69-
Here, [**ref 1**] is a small user code to read the measurement result via a local variable `__cycle_count__` . This User Code is optional. If you don't put anything here, the measured result will be shown with a `__perf_counter_printf__`.
69+
Here, [**ref 1**] is a small user code to read the measurement result via a local variable `__cycle_count__`. This User Code is optional. If you don't put anything here, the measured result will be shown with a `__perf_counter_printf__`.
7070
7171
#### **Example 1:** Simple measurement with printf
7272
@@ -78,7 +78,7 @@ Here, [**ref 1**] is a small user code to read the measurement result via a loca
7878
}
7979
```
8080

81-
You will see the measured result in console:
81+
You will see the measured result in the console:
8282

8383
![image-20220509004258020](./documents/pictures/__cycleof___output_simple)
8484

@@ -87,18 +87,18 @@ You will see the measured result in console:
8787
#### **Example 2:** Read measured result via `__cycle_counter__`
8888

8989
```c
90-
int32_t iCycleResult = 0;
90+
int64_t lCycleResult = 0;
9191

9292
/* measure cycles and store it in a dedicated variable without printf */
9393
__cycleof__("delay_us(1000ul)",
9494
/* insert code to __cycleof__ body, "{}" can be omitted */
9595
{
96-
iCycleResult = __cycle_count__; /*< "__cycle_count__" stores the result */
96+
lCycleResult = __cycle_count__; /*< "__cycle_count__" stores the result */
9797
}) {
9898
delay_us(1000ul);
9999
}
100100

101-
printf("\r\n delay_us(1000ul) takes %d cycles\r\n", (int)iCycleResult);
101+
printf("\r\n delay_us(1000ul) takes %lld cycles\r\n", lCycleResult);
102102
```
103103
104104
The result is read out from `__cycle_count__`and used in other place:
@@ -109,12 +109,12 @@ The result is read out from `__cycle_count__`and used in other place:
109109
110110
#### 1.2.1 CPU Usage
111111
112-
For both bare-metal and OS environment, you can measure the CPU Usage with macro `__cpu_usage__()` for a given code segment as long as it is executed repeatedly.
112+
For both bare-metal and OS environments, you can measure the CPU Usage with macro `__cpu_usage__()` for a given code segment as long as it is executed repeatedly.
113113
114114
**Syntax**
115115
116116
```c
117-
__cycleof__(<Iteration Count before getting an average result>, [User Code, see ref 1]) {
117+
__cpu_usage__(<Iteration Count before getting an average result>, [User Code, see ref 1]) {
118118
//! target code segment of measurement
119119
...
120120
}
@@ -177,7 +177,7 @@ __cpu_perf__(<Description String for the target>, [User Code, see ref 1]) {
177177
}
178178
```
179179
180-
Here, [**ref 1**] is a small user code to read the measurement result via a local **struct** variable `__PERF_INFO__` . This User Code is optional. If you don't put anything here, the measured result will be shown with a `__perf_counter_printf__`. The prototype of the `__PERF_INFO__` is shown below:
180+
Here, [**ref 1**] is a small user code to read the measurement result via a local **struct** variable `__PERF_INFO__`. This User Code is optional. If you don't put anything here, the measured result will be shown with a `__perf_counter_printf__`. The prototype of the `__PERF_INFO__` is shown below:
181181
182182
```c
183183
struct {
@@ -192,7 +192,7 @@ struct {
192192
} __PERF_INFO__;
193193
```
194194

195-
For example, when insert user code, you can read CPI from `__PERF_INFO__.fCPI`.
195+
For example, when inserting user code, you can read CPI from `__PERF_INFO__.fCPI`.
196196

197197
**Example 1: measure the Coremark**
198198

@@ -223,13 +223,13 @@ The result might look like the following:
223223
224224
### 1.3 Timestamp
225225
226-
You can get the system timestamp (since the initialization of perf_counter service) via function `get_system_ticks()` and `get_system_ms()`.
226+
You can get the system timestamp (since the initialization of perf_counter service) via the functions `get_system_ticks()` and `get_system_ms()`.
227227
228228
**NOTE**: The `get_system_ms()` is **NOT** a wrapper of the function `get_system_ticks()`.
229229
230230
231231
232-
There are various way to take advantage of those functions.
232+
There are various ways to take advantage of those functions.
233233
234234
#### Example 3: Use `get_system_ms()` as random seed
235235
@@ -244,7 +244,7 @@ int main (void)
244244
245245
n = 5;
246246
247-
/* Intializes random number generator */
247+
/* Initialize random number generator */
248248
srand((unsigned) get_system_ticks());
249249
250250
/* Print 5 random numbers from 0 to 1024 */
@@ -270,7 +270,7 @@ int main (void)
270270
} while(0);
271271
```
272272
273-
This example shows how to use the delta value of `get_system_ticks()` to measure the CPU cycles used by specified code segment. In fact, the `__cycleof__()` is implemented in the same way:
273+
This example shows how to use the delta value of `get_system_ticks()` to measure the CPU cycles used by a specified code segment. In fact, the `__cycleof__()` is implemented in the same way:
274274
275275
```c
276276
#define __cycleof__(__STR, ...) \
@@ -294,7 +294,7 @@ This example shows how to use the delta value of `get_system_ticks()` to measure
294294

295295
### 1.4 Timer Services
296296

297-
perf_counter provides the basic timer services for delaying a given period of time and polling-for-timeout. For example:
297+
perf_counter provides the basic timer services for delaying a given period and polling-for-timeout. For example:
298298

299299
```c
300300
delay_ms(1000); /* block the program for 1000ms */
@@ -315,9 +315,9 @@ while(1) {
315315
316316
### 1.5 Work with EventRecorder in MDK
317317
318-
If you are using EventRecorder in MDK, once you deployed the `perf_counter`, it will provide the timer service for EventRecorder by implenting the following functions: `EventRecorderTimerSetup()`, `EventRecorderTimerGetFreq()` and `EventRecorderTimerGetCount()`.
318+
If you are using EventRecorder in MDK, once you deploy the `perf_counter`, it will provide the timer service for EventRecorder by implementing the following functions: `EventRecorderTimerSetup()`, `EventRecorderTimerGetFreq()` and `EventRecorderTimerGetCount()`.
319319
320-
If you have not modify anything in `EventRecorderConf.h`, **you don't have to**, and please keep the default configuration. If you see warnings like this:
320+
If you have not modified anything in `EventRecorderConf.h`, **you don't have to**, and please keep the default configuration. If you see warnings like this:
321321
322322
```
323323
Invalid Time Stamp Source selected in EventRecorderConf.h!
@@ -329,7 +329,7 @@ Please set the macro `EVENT_TIMESTAMP_SOURCE` to `3` to suppress it.
329329
330330
331331
332-
**By using perf_counter as the reference clock, EventRecorder can have the highest clock resolution on the target system without worring about the presence of DWT or any conflicting usage of SysTick.**
332+
**By using perf_counter as the reference clock, EventRecorder can have the highest clock resolution on the target system without worrying about the presence of DWT or any conflicting usage of SysTick.**
333333
334334
335335
@@ -347,7 +347,7 @@ If you want to change the System Frequency, **after** the change, make sure:
347347
348348
#### 1.6.2 Reconfigure the SysTick
349349
350-
Some systems (e.g. FreeRTOS) might reconfigure the systick timer to fulfil the requirement of their feature. To support this:
350+
Some systems (e.g., FreeRTOS) might reconfigure the systick timer to fulfill the requirements of their feature. To support this:
351351
352352
1. **Before the reconfiguration**, please call function `before_cycle_counter_reconfiguration()`.
353353
@@ -363,7 +363,7 @@ Some systems (e.g. FreeRTOS) might reconfigure the systick timer to fulfil the r
363363
364364
#### 2.1.1 For Bare-metal:
365365
366-
1. Clone the code to your local with following command lines:
366+
1. Clone the code to your local with the following command lines:
367367
368368
```shell
369369
git clone https://github.com/GorgonMeducer/perf_counter.git
@@ -374,14 +374,14 @@ git clone https://github.com/GorgonMeducer/perf_counter.git
374374

375375
> **NOTE**: Please do **NOT** add any assembly source files of this `perf_counter` library to your compilation, i.e. `systick_wrapper_gcc.S`, `systick_wrapper_gnu.s` or `systick_wrapper_ual.s`.
376376
377-
4. Include `perf_counter.h` in corresponding c source file:
377+
4. Include `perf_counter.h` in the corresponding c source file:
378378

379379
```c
380380
#include "perf_counter.h"
381381
```
382382

383383

384-
5. Make sure your system contains the CMSIS (with a version 5.7.0 or above) as `perf_counter.h` includes `cmsis_compiler.h`.
384+
5. Make sure your system contains the CMSIS (with version 5.7.0 or above) as `perf_counter.h` and includes `cmsis_compiler.h`.
385385
6. Call the function `perfc_port_insert_to_system_timer_insert_ovf_handler()` in your `SysTick_Handler()`
386386

387387
```c
@@ -394,9 +394,9 @@ void SysTick_Handler(void)
394394
```
395395
396396
397-
7. Make sure the `SystemCoreClock` is updated with the same value as CPU frequency.
397+
7. Ensure the `SystemCoreClock` is updated with the same value as CPU frequency.
398398
8. **IMPORTANT**: Make sure the `SysTick_CTRL_CLKSOURCE_Msk` bit ( bit 2) of `SysTick->CTRL` register is `1` that means SysTick runs with the same clock source as the target Cortex-M processor.
399-
9. Initialize the perf_counter with boolean value that indicates whether the user applications and/or RTOS have already occupied the SysTick.
399+
9. Initialize the perf_counter with a boolean value that indicates whether the user applications and/or RTOS have already occupied the SysTick.
400400
401401
```c
402402
void main(void)
@@ -413,7 +413,7 @@ void main(void)
413413
SystemCoreClockUpdate();
414414
415415
/*! \brief initialize perf_counter() and pass true if SysTick is
416-
*! occupied by user applications or RTOS, otherwise pass
416+
*! occupied by user applications or RTOS; otherwise, pass
417417
*! false.
418418
*/
419419
init_cycle_counter(true);
@@ -425,16 +425,16 @@ void main(void)
425425
}
426426
```
427427

428-
10. **IMPORTANT**: Please enable GNU extension in your compiler. For **GCC** and **CLANG**, it is `--std=gnu99` or `--std=gnu11`, and for other compilers, please check the user manual first. Failed to do so, you will not only trigger the warning in `perf_counter.h`, but also lose the function correctness of `__cycleof__()` and `__super_loop_monitor__()`, because `__PLOOC_VA_NUM_ARGS()` isn't report `0` when passed with no argument.
428+
10. **IMPORTANT**: Please enable the GNU extension in your compiler. For **GCC** and **CLANG**, it is `--std=gnu99` or `--std=gnu11`, and for other compilers, please check the user manual first. Fail to do so, you will not only trigger the warning in `perf_counter.h`, but also lose the function correctness of `__cycleof__()` and `__super_loop_monitor__()`, because `__PLOOC_VA_NUM_ARGS()` doesn't report `0` when passed with no argument.
429429

430430
```c
431431
#if __PLOOC_VA_NUM_ARGS() != 0
432-
#warning Please enable GNC extensions, it is required by __cycleof__() and \
432+
#warning Please enable GNC extensions that is required by __cycleof__() and \
433433
__super_loop_monitor__()
434434
#endif
435435
```
436436

437-
11. It is nice to add macro definition `__PERF_COUNTER__` to your project GLOBALLY. It helps other module to detect the existence of perf_counter. For Example, LVGL [`lv_conf_cmsis.h`](https://github.com/lvgl/lvgl/blob/d367bb7cf17dc34863f4439bba9b66a820088951/env_support/cmsis-pack/lv_conf_cmsis.h#L81-L99) use this macro to detect perf_counter and uses `get_system_ms()` to implement `lv_tick_get()`.
437+
11. It is nice to add macro definition `__PERF_COUNTER__` to your project GLOBALLY. It helps other modules to detect the existence of perf_counter. For Example, LVGL [`lv_conf_cmsis.h`](https://github.com/lvgl/lvgl/blob/d367bb7cf17dc34863f4439bba9b66a820088951/env_support/cmsis-pack/lv_conf_cmsis.h#L81-L99) use this macro to detect perf_counter and uses `get_system_ms()` to implement `lv_tick_get()`.
438438

439439

440440

@@ -446,7 +446,7 @@ __super_loop_monitor__()
446446

447447
1. Download the cmsis-pack from the`cmsis-pack` folder. It is a file with name `GorgonMeducer.perf_counter.<version>.pack`, for example `GorgonMeducer.perf_counter.2.2.0.pack`
448448

449-
2. Double click it to install this cmsis-pack. Once finished, you can find it in your Pack-Installer:
449+
2. Double-click it to install this cmsis-pack. Once finished, you can find it in your Pack-Installer:
450450

451451
![](./documents/pictures/pack_installer)
452452
In the future, you can pull the latest version of perf_counter from the menu `Packs->Check For Updates` as shown below:
@@ -459,25 +459,25 @@ __super_loop_monitor__()
459459

460460
![](./documents/pictures\RTE)
461461

462-
4. Include `perf_counter.h` in corresponding c source file:
462+
4. Include `perf_counter.h` in the corresponding c source file:
463463

464464
```c
465465
#include "perf_counter.h"
466466
```
467467

468468

469-
5. Make sure your system contains the CMSIS (with a version 5.7.0 or above) as `perf_counter.h` includes `cmsis_compiler.h`. Usually, you should do this with RTE as shown below:
469+
5. Make sure your system contains the CMSIS (version 5.7.0 or above) as `perf_counter.h` and includes `cmsis_compiler.h`. Usually, you should do this with RTE, as shown below:
470470

471471
![image-20220509012432408](./documents/pictures/RTE_cmsis_core)
472472

473-
6. Make sure the `SystemCoreClock` is updated with the same value as CPU frequency.
473+
6. Ensure the `SystemCoreClock` is updated with the same value as CPU frequency.
474474
7. **IMPORTANT**: Make sure the `SysTick_CTRL_CLKSOURCE_Msk` bit ( bit 2) of `SysTick->CTRL` register is `1` that means SysTick runs with the same clock source as the target Cortex-M processor.
475-
8. Initialize the perf_counter with boolean value that indicates whether the user applications and/or RTOS have already occupied the SysTick.
475+
8. Initialize the perf_counter with a boolean value that indicates whether the user applications and/or RTOS have already occupied the SysTick.
476476

477477
```c
478478
void main(void)
479479
{
480-
//! setup system clock
480+
//! Setup system clock
481481

482482
/*! \brief Update SystemCoreClock with the latest CPU frequency
483483
*! If the function doesn't exist or doesn't work correctly,
@@ -489,7 +489,7 @@ void main(void)
489489
SystemCoreClockUpdate();
490490

491491
/*! \brief initialize perf_counter() and pass true if SysTick is
492-
*! occupied by user applications or RTOS, otherwise pass
492+
*! occupied by user applications or RTOS; otherwise, pass
493493
*! false.
494494
*/
495495
init_cycle_counter(true);
@@ -501,28 +501,28 @@ void main(void)
501501
}
502502
```
503503
504-
9. **IMPORTANT**: Please enable GNU extension in your compiler.
504+
9. **IMPORTANT**: Please enable the GNU extension in your compiler.
505505
506-
For Arm Compiler 5, please select both **C99 mode** and GNU extensions in the **Option for target dialog** as shown below:
506+
For Arm Compiler 5, please select both **C99 mode** and GNU extensions in the **Option for target dialogue** as shown below:
507507
508508
![image-20220509012752097](./documents/pictures/GNU_in_AC5)
509509
510510
For Arm Compiler 6, please select **gnu99** or **gnu11** in Language C drop-list as shown below:
511511
512512
![image-20220509012944724](./documents/pictures/gnu_in_ac6)
513513
514-
Failed to do so, you will not only trigger the warning in `perf_counter.h`, but also lose the function correctness of `__cycleof__()` and `__super_loop_monitor__()`, because `__PLOOC_VA_NUM_ARGS()` isn't report `0` when passed with no argument.
514+
Failed to do so, you will not only trigger the warning in `perf_counter.h`, but also lose the function correctness of `__cycleof__()` and `__super_loop_monitor__()`, because `__PLOOC_VA_NUM_ARGS()` doesn't report `0` when passed with no argument.
515515
516516
```c
517517
#if __PLOOC_VA_NUM_ARGS() != 0
518-
#warning Please enable GNC extensions, it is required by __cycleof__() and \
518+
#warning Please enable GNC extensions, that is required by __cycleof__() and \
519519
__super_loop_monitor__()
520520
#endif
521521
```
522522

523523
### 2.3 Use perf_counter in RT-Thread RTOS
524524

525-
perf_counter has registered as one of the [RT-Thread software packages](https://packages.rt-thread.org/en/detail.html?package=perf_counter), which locats in `system` category. In [ENV](https://www.rt-thread.io/download.html?download=Env) or [RT-Thread Studio](https://www.rt-thread.io/download.html?download=Studio), you just need to simply enable cputime framework. RT-Thread will automatically enable perf_counter if you are using Cortex-M architecture.
525+
perf_counter has registered as one of the [RT-Thread software packages](https://packages.rt-thread.org/en/detail.html?package=perf_counter), which locats in `system` category. In [ENV](https://www.rt-thread.io/download.html?download=Env) or [RT-Thread Studio](https://www.rt-thread.io/download.html?download=Studio), you just need to enable `cputime` framework. RT-Thread will automatically enable perf_counter if you are using Cortex-M architecture.
526526

527527
![rt-thread-settings](./documents/pictures/rt-thread-settings.png)
528528

@@ -534,7 +534,7 @@ perf_counter has registered as one of the [RT-Thread software packages](https://
534534

535535
### 3.1 Why I see `Undefined symbol $Super$$SysTick_Handler`
536536

537-
This error usually pops up in **Arm Compiler 5** and **Arm Compiler 6**. It is because you haven't implemented any non-weak `SysTick_Handler()`. Please provide an EMPTY one in any c source file to solve this problem:
537+
This error usually appears in **Arm Compiler 5** and **Arm Compiler 6**. It is because you haven't implemented any non-weak `SysTick_Handler()`. Please provide an EMPTY one in any c source file to solve this problem:
538538

539539
```c
540540
void SysTick_Handler(void)
@@ -546,7 +546,7 @@ void SysTick_Handler(void)
546546
547547
### 3.2 Why do I see perf_counter in red in the MDK project manager?
548548
549-
Since version v2.1.0 I removed the unnecessary bundle feature from the cmsis-pack. If you have used the older version, you will encounter this issue. To solve this problem:
549+
Since version v2.1.0, I removed the unnecessary bundle feature from the cmsis-pack. If you have used the older version, you will encounter this issue. To solve this problem:
550550
551551
1. please unselect ALL the performance components in RTE, press OK and close the uVision.
552552
2. reopen the mdk project and select the perf_counter components in RTE

0 commit comments

Comments
 (0)