1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/cpu
bors[bot] 0607806caa
Merge #19263
19263: cpu/stm32/periph/timer: don't stop counter r=maribu a=Enoch247

### Contribution description

From the git comment msg:

If a timer's channel was set with a really small realtive duration from now, such that it would be missed (underflowed), the driver would stop the timer, potentially causing missed ticks. It was stopped to ensure that the channel's output-compare register could be set to the current counter value, before re-enabling the timer's counter. This is a condition that will ensure that the underflow won't happen again and the interrupt will fire, at the cost of losing some ticks for very high speed clocks.

This patch replaces the logic that stopped the timer. Instead it uses a register provided by the timer hardware to trigger timer interrupts via software.


### Testing procedure

1. do
    ``` bash
    $ cd tests/periph_timer_short_relative_set
    $ make BOARD=nucleo-f303ze flash term
    ```
1. follow prompts to run test
1. observe all tests pass
1. apply patch below to break test
1. rerun test
1. observe test fails, so new method is doing its job


##### patch to intentionally break test

```` diff
diff --git a/cpu/stm32/periph/timer.c b/cpu/stm32/periph/timer.c
index 64a6f3a656..7078c46ab4 100644
--- a/cpu/stm32/periph/timer.c
+++ b/cpu/stm32/periph/timer.c
`@@` -177,7 +177,7 `@@` int timer_set(tim_t tim, int channel, unsigned int timeout)
     if (value > timeout) {
         /* time till timeout is larger than requested --> timer already expired
          * ==> let's make sure we have an IRQ pending :) */
-        dev(tim)->EGR |= (TIM_EGR_CC1G << channel);
+        //dev(tim)->EGR |= (TIM_EGR_CC1G << channel);
     }
````


### Issues/PRs references

- none known


Co-authored-by: Joshua DeWeese <jdeweese@primecontrols.com>
2023-02-09 08:06:31 +00:00
..
arm7_common cpu/arm7_common: drop cyclic include 2022-12-13 15:55:17 +01:00
atmega32u4 cpu/atmega_common: implement periph/gpio_ll{,_irq} 2022-05-02 14:44:55 +02:00
atmega128rfa1 cpu/atmega128rfa1/Kconfig: select default transceiver 2023-01-19 15:34:19 +01:00
atmega256rfr2 cpu/atmega256rfr2/Kconfig: select default transceiver 2023-01-19 15:34:19 +01:00
atmega328p cpu/atmega_common: implement periph/gpio_ll{,_irq} 2022-05-02 14:44:55 +02:00
atmega1281 cpu/atmega_common: implement periph/gpio_ll{,_irq} 2022-05-02 14:44:55 +02:00
atmega1284p cpu/atmega_common: implement periph/gpio_ll{,_irq} 2022-05-02 14:44:55 +02:00
atmega2560 cpu/atmega_common: implement periph/gpio_ll{,_irq} 2022-05-02 14:44:55 +02:00
atmega_common core/lib: Add macros/utils.h header 2023-01-07 09:47:44 +01:00
atxmega Merge pull request #18619 from maribu/core/mutex/cleanup 2022-10-03 10:58:07 +02:00
avr8_common Merge #18763 2023-01-14 22:41:37 +00:00
cc26x0_cc13x0 cpu: call early_init() 2023-01-08 22:26:12 +01:00
cc26x2_cc13x2 cpu: call early_init() 2023-01-08 22:26:12 +01:00
cc26xx_cc13xx boards/common/cc26xx_cc13xx: Fix flashing with upstream OpenOCD 2023-01-10 22:39:35 +01:00
cc2538 cpu: call early_init() 2023-01-08 22:26:12 +01:00
cortexm_common cpu/common_cortex: handling RIOTBOOT_LEN for tinyusb_dfu 2023-01-15 18:09:55 +01:00
efm32 cpu: call early_init() 2023-01-08 22:26:12 +01:00
esp32 boards: add support for ESP32 ProS3 board 2023-02-06 16:19:11 +01:00
esp8266 cpu: call early_init() 2023-01-08 22:26:12 +01:00
esp_common cpu/esp_common/freertos: Handle NULL being passed to vTaskDelete 2023-01-24 17:48:13 +00:00
fe310 cpu: call early_init() 2023-01-08 22:26:12 +01:00
gd32v Merge #17045 #19243 2023-02-07 17:39:20 +00:00
kinetis cpu: call early_init() 2023-01-08 22:26:12 +01:00
lm4f120 cpu: call early_init() 2023-01-08 22:26:12 +01:00
lpc23xx cpu: call early_init() 2023-01-08 22:26:12 +01:00
lpc1768 cpu: call early_init() 2023-01-08 22:26:12 +01:00
msp430_common cpu: call early_init() 2023-01-08 22:26:12 +01:00
msp430fxyz cpu/msp430: add Kconfig 2021-12-02 16:33:19 +01:00
native Merge #18100 #19121 #19164 #19169 2023-01-18 23:59:58 +00:00
nrf5x_common cpu/nrf5x_common: Implement timer_set() 2022-12-23 14:48:08 +01:00
nrf51 cpu: call early_init() 2023-01-08 22:26:12 +01:00
nrf52 Merge #19010 #19149 2023-01-15 23:31:00 +00:00
nrf9160 cpu: call early_init() 2023-01-08 22:26:12 +01:00
qn908x cpu: call early_init() 2023-01-08 22:26:12 +01:00
riscv_common cpu/riscv_common/periph_timer: Fix timer_clear() 2023-01-09 00:08:59 +01:00
rpx0xx cpu: call early_init() 2023-01-08 22:26:12 +01:00
sam0_common cpu/sam0_common: fix static checks in periph_cpu_common.h 2023-01-18 01:54:34 +01:00
sam3 cpu: call early_init() 2023-01-08 22:26:12 +01:00
sam_common cpu/sam_common: make use of cortexm.ld 2022-09-23 15:55:12 +02:00
samd5x cpu/sam0_common: move adc_res_t to common code 2023-01-17 17:18:07 +01:00
samd21 cpu/sam0_common: move adc_res_t to common code 2023-01-17 17:18:07 +01:00
saml1x cpu/sam0_common: move adc_res_t to common code 2023-01-17 17:18:07 +01:00
saml21 cpu/sam0_common: move adc_res_t to common code 2023-01-17 17:18:07 +01:00
stellaris_common
stm32 cpu/stm32/periph/timer: don't stop counter 2023-02-08 14:08:56 -05:00
doc.txt docs/doxygen : Add CPU section 2021-07-09 10:47:42 +02:00
Kconfig treewide: change Kconfig prefix for module symbols 2020-08-31 09:57:28 +02:00