diff --git a/README.md b/README.md new file mode 100644 index 0000000..ec4b521 --- /dev/null +++ b/README.md @@ -0,0 +1,30 @@ +für zephr: +``` +#include +#include + +static volatile uint16_t target_val = 0; +static uint16_t akku = 0; + +// Direct ISR deklarieren – minimaler Overhead! +ISR_DIRECT_DECLARE(my_pwm_dither_isr) +{ + // 1. Hardware Interrupt-Flag löschen (direkt übers CMSIS-Register) + TIMx->SR = ~TIM_SR_UIF; + + // 2. Deine Akku-Rechnung + akku += target_val; + TIMx->CCR1 = (akku >> 6); + akku &= 0x3F; + + // 3. Kein Reschedule nötig, da wir keine Zephyr-API in der ISR aufrufen + return 0; +} + +void init_pwm_dither(void) +{ + // Interrupt in Zephyr registrieren (Priority z.B. 1 oder 2) + IRQ_DIRECT_CONNECT(TIMx_IRQn, 1, my_pwm_dither_isr, 0); + irq_enable(TIMx_IRQn); +} +```