2026-08-02 11:23:10 +02:00
2026-08-02 07:11:34 +02:00
2026-08-02 07:11:34 +02:00
2026-08-02 07:11:34 +02:00
2026-08-02 07:11:34 +02:00
2026-08-02 11:23:10 +02:00

für zephr:

#include <zephyr/kernel.h>
#include <zephyr/arch/cpu.h>

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; // Behält die letzten 6 Bits: der Rest der Bit-Shift-Division

    // 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);
}
Description
Node for driving/dimming CC LEDs modules found in AC lamps, but for 12V and with CAN interface.
Readme 99 KiB
Languages
KiCad Layout 100%