aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/STM32/LLD/TIMv1
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2017-12-26 08:39:31 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2017-12-26 08:39:31 +0000
commiteb4d8034884b2093b322deb165227135c534ebb4 (patch)
tree39700d12fd0bafc51dfad7d212ed9d18e738fc70 /os/hal/ports/STM32/LLD/TIMv1
parenta4122ca7d5f78b0fd23e9b594aaa2c9d5c46d70f (diff)
downloadChibiOS-eb4d8034884b2093b322deb165227135c534ebb4.tar.gz
ChibiOS-eb4d8034884b2093b322deb165227135c534ebb4.tar.bz2
ChibiOS-eb4d8034884b2093b322deb165227135c534ebb4.zip
Frequencies are right finally.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11185 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/ports/STM32/LLD/TIMv1')
-rw-r--r--os/hal/ports/STM32/LLD/TIMv1/hal_st_lld.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/os/hal/ports/STM32/LLD/TIMv1/hal_st_lld.c b/os/hal/ports/STM32/LLD/TIMv1/hal_st_lld.c
index 691ffb1b4..fb0cccdac 100644
--- a/os/hal/ports/STM32/LLD/TIMv1/hal_st_lld.c
+++ b/os/hal/ports/STM32/LLD/TIMv1/hal_st_lld.c
@@ -33,9 +33,9 @@
#if OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING
#if (OSAL_ST_RESOLUTION == 32)
-#define ST_ARR_INIT 0xFFFFFFFF
+#define ST_ARR_INIT 0xFFFFFFFFU
#else
-#define ST_ARR_INIT 0x0000FFFF
+#define ST_ARR_INIT 0x0000FFFFU
#endif
#if STM32_ST_USE_TIMER == 2
@@ -180,11 +180,17 @@
#if OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC
-#if STM32_HCLK % OSAL_ST_FREQUENCY != 0
+#if defined(STM32_CORE_CK)
+#define SYSTICK_CK STM32_CORE_CK
+#else
+#define SYSTICK_CK STM32_HCLK
+#endif
+
+#if SYSTICK_CK % OSAL_ST_FREQUENCY != 0
#error "the selected ST frequency is not obtainable because integer rounding"
#endif
-#if (STM32_HCLK / OSAL_ST_FREQUENCY) - 1 > 0xFFFFFF
+#if (SYSTICK_CK / OSAL_ST_FREQUENCY) - 1 > 0xFFFFFF
#error "the selected ST frequency is not obtainable because SysTick timer counter limits"
#endif
@@ -292,7 +298,7 @@ void st_lld_init(void) {
#if OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC
/* Periodic systick mode, the Cortex-Mx internal systick timer is used
in this mode.*/
- SysTick->LOAD = (STM32_HCLK / OSAL_ST_FREQUENCY) - 1;
+ SysTick->LOAD = (SYSTICK_CK / OSAL_ST_FREQUENCY) - 1;
SysTick->VAL = 0;
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
SysTick_CTRL_ENABLE_Msk |