I use the Timer0 with a very low frequency of 134 seconds. In the simulation it works fine, but with the microchip I get only 2 seconds, see flowcode.
Who can help me?
Kind regards
Jan
Timer0
Moderator: Benj
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Timer0
Hi Jan,
Hmm the generated code looks ok to me.
What if you clear the timer count registers before enabling the interrupt.
Using a C icon.
Hmm the generated code looks ok to me.
Code: Select all
// Name: Interrupt 134 seconds, Type: Interrupt: Enable TMR0
T0CON1 = (T0CON1 & 0x1F) | 0x40;
st_bit(T0CON1,T0ASYNC);
T0CON1 = (T0CON1 & 0xF0) | 0x0E;
T0CON0 = 0x90;
st_bit(INTCON,GIE);
st_bit(PIE0, TMR0IE);
Using a C icon.
Code: Select all
TMR0L = 0;
TMR0H = 0;
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
Re: Timer0
Hi Ben,
That works OK now. The timer0 works correctly.
But the timer1 was a factor 4 times faster as expected. The problem could be solved by changing the clock source from Fosc to Fosc/4. But flowcode showed in both cases the same frequency. In case Fosc will be choosen, the frequency must be 61.035 x 4 Hz.
Kind regards
Jan
That works OK now. The timer0 works correctly.
But the timer1 was a factor 4 times faster as expected. The problem could be solved by changing the clock source from Fosc to Fosc/4. But flowcode showed in both cases the same frequency. In case Fosc will be choosen, the frequency must be 61.035 x 4 Hz.
Kind regards
Jan
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
Re: Timer0
Hi Ben
I still have problems with the frequency of the timers with the PIC16LF18857 microchip.
Above problems with timer1. But thesame problem will be met with timer0, which is 4 times faster as expected. The settings are:
Clock source: HFINTOSC
Input Asyn.: FOSC/4
Prescaler: 1:512
Postscaler: 1:1 The C-code seems correct to me
The frequency is 4 times faster, independent of the prescaler and postscaler.
Is there a solution for this problem?
Kind regards
Jan
I still have problems with the frequency of the timers with the PIC16LF18857 microchip.
Above problems with timer1. But thesame problem will be met with timer0, which is 4 times faster as expected. The settings are:
Clock source: HFINTOSC
Input Asyn.: FOSC/4
Prescaler: 1:512
Postscaler: 1:1 The C-code seems correct to me
The frequency is 4 times faster, independent of the prescaler and postscaler.
Is there a solution for this problem?
Kind regards
Jan