File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -156,8 +156,9 @@ from A0 to A15, to input mode:
156156 * (volatile uint32_t *) (0x40020000 + 0 ) = 0 ; // Set A0-A15 to input mode
157157```
158158
159- Note the volatile specifier. The meaning of it will be covered later. By
160- setting individual bits, we can selectively set specific pins to a desired
159+ > Note the ` volatile ` specifier. Its meaning will be covered later.
160+
161+ By setting individual bits, we can selectively set specific pins to a desired
161162mode. For example, this snippet sets pin A3 to output mode:
162163
163164``` c
@@ -868,6 +869,12 @@ void SysTick_Handler(void) {
868869}
869870` ` `
870871
872+ > The ` volatile` specifier is required here becase ` s_ticks` is modified by the
873+ > interrupt handler. ` volatile` prevents the compiler to optimise/cache
874+ > ` s_ticks` value in a CPU register: instead, generated code always accesses
875+ > memory. That is why you will find ` volatile` keywords later in the
876+ > peripheral, too.
877+
871878Note the ` volatile` specifier for ` s_ticks` . Any variable that is changed
872879by the IRQ handler, must be marked as ` volatile` , in order to prevent the
873880compiler to optimize the operation by caching its value in a register.
You can’t perform that action at this time.
0 commit comments