Port-arm archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Incorrect prescalar calculation for watchdog timer



Hi,

Cortex watchdog timer prescalar calculation seems to be wrong and is
leading to overflow in the prescalar. Due to this watchdog timer is
firing at incorrect interval. This problem will only be observed when
the frequency is not exactly divisible by 256.

In a9wdt_attach, Prescalar is calculated as
        size_t div;
        for (div = 256; div >= 2; div++) {
            if (sc->sc_freq % div == 0) {
                sc->sc_wdog_prescaler = div;
                break;
            }
        }

This will lead to prescalar value of 256 or more, where as it should
be 256 or less. The for loop here should have '--' instead of '++'.

Thanks,
~Manjul


Home | Main Index | Thread Index | Old Index