diff --git a/examples/systick_irq/README.md b/examples/systick_irq/README.md index 732b29bc679d1a063229888c6a66b198b0a7e58d..26e561ef98affb57cc7e1b2b8c752c089c86b81e 100644 --- a/examples/systick_irq/README.md +++ b/examples/systick_irq/README.md @@ -4,11 +4,11 @@ interrupts for timing. Many bare-metal and RTOS based embedded applications will use the Systick IRQ for timing, periodic housekeeping and task arbitration so knowing how to set that up is useful. -Note that this example is *NOT* compatible with the Delay_Ms() function that's -part of the ch32v003fun library - that function uses the Systick counter for -doing busy-wait delays and will interfere with its use in generating predictable -IRQs. Do not use the built-in Delay_Ms() and related functions when using Systick -for IRQs. +Note that this example is *NOT* compatible with the Delay_*() functions that are +part of the ch32v003fun library - those functions use the Systick counter for +doing busy-wait delays and assume that the CNT register rolls over at 32-bit +maximum. Do not use the built-in Delay_Ms() and related functions when using +Systick for IRQs. Note also the use of the `__attribute__((interrupt))` syntax in declaring the IRQ handler. Some of the IRQ examples from the WCH HAL library have slightly diff --git a/examples/systick_irq/systick_irq.c b/examples/systick_irq/systick_irq.c index 0ec6631adb0e58d553a3bfe8f97afb0bb7b59091..6091b1e87d83b302a49c1cbeb9a74a4f827b443d 100644 --- a/examples/systick_irq/systick_irq.c +++ b/examples/systick_irq/systick_irq.c @@ -25,6 +25,9 @@ volatile uint32_t systick_cnt; */ void systick_init(void) { + /* disable default SysTick behavior */ + SysTick->CTLR = 0; + /* enable the SysTick IRQ */ NVIC_EnableIRQ(SysTicK_IRQn);