Skip to content
Snippets Groups Projects
Commit 08d5168f authored by cnlohr's avatar cnlohr
Browse files

Merge branch 'master' of https://github.com/cnlohr/ch32v003fun

parents be034393 03b71e77
No related branches found
No related tags found
No related merge requests found
...@@ -4,11 +4,11 @@ interrupts for timing. Many bare-metal and RTOS based embedded applications will ...@@ -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 use the Systick IRQ for timing, periodic housekeeping and task arbitration so
knowing how to set that up is useful. knowing how to set that up is useful.
Note that this example is *NOT* compatible with the Delay_Ms() function that's Note that this example is *NOT* compatible with the Delay_*() functions that are
part of the ch32v003fun library - that function uses the Systick counter for part of the ch32v003fun library - those functions use the Systick counter for
doing busy-wait delays and will interfere with its use in generating predictable doing busy-wait delays and assume that the CNT register rolls over at 32-bit
IRQs. Do not use the built-in Delay_Ms() and related functions when using Systick maximum. Do not use the built-in Delay_Ms() and related functions when using
for IRQs. Systick for IRQs.
Note also the use of the `__attribute__((interrupt))` syntax in declaring the 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 IRQ handler. Some of the IRQ examples from the WCH HAL library have slightly
......
...@@ -25,6 +25,9 @@ volatile uint32_t systick_cnt; ...@@ -25,6 +25,9 @@ volatile uint32_t systick_cnt;
*/ */
void systick_init(void) void systick_init(void)
{ {
/* disable default SysTick behavior */
SysTick->CTLR = 0;
/* enable the SysTick IRQ */ /* enable the SysTick IRQ */
NVIC_EnableIRQ(SysTicK_IRQn); NVIC_EnableIRQ(SysTicK_IRQn);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment