From 7df5ddf72cd8226efbdf127721bbe14bf1cfccc2 Mon Sep 17 00:00:00 2001 From: Eric Brombaugh <ebrombaugh1@cox.net> Date: Mon, 24 Apr 2023 12:42:32 -0700 Subject: [PATCH] Updated for latest SysTick changes in ch32v003fun library. --- examples/systick_irq/README.md | 10 +++++----- examples/systick_irq/systick_irq.c | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/systick_irq/README.md b/examples/systick_irq/README.md index 732b29b..26e561e 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 0ec6631..6091b1e 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); -- GitLab