🇩🇪
void initTimer(void) {
/*
T0CONbits.T08BIT = 1; // 0 - 16 bit; 1 - 8 bit
T0CONbits.T0CS = 0; // 0 = Internal clock (FOSC/4)
T0CONbits.PSA = 0; // 0 = Timer0 prescaler is assigned. Timer0 clock input comes from prescaler output.
T0CONbits.T0PS = 7; // Prescaler 1:32
T0CONbits.TMR0ON = 1; // 1 - Timer enabled
*/
INTCONbits.TMR0IF = 0; // Clear Timer0 overflow flag
INTCONbits.TMR0IE = 1; // Enable Timer0 overflow interrupt
//TMR0ON T08BIT T0CS T0SE PSA T0PS2 T0PS1 T0PS0
// 1 1 0 0? 0 1 0 0
T0CON = 0xc4;
}
void TimerIsr(void) {
/* ##### TIMER0 10 ms bei 40MHz ######
8 Bit 1:32 / Clock_Rate 10ms
(256*32*4)/(40*10^6 s^-1 * 10^10-3 s) = 8,192E-2 =(256/3125)
*/
INTCONbits.TMR0IF = 0;
timer_inc += 256;
if (timer_inc >= 3125) {
timer_inc -= 3125; // = 10 ms vorbei
timer10ms++;