News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

18F TMR0

Started by joesaliba, Jul 24, 2022, 03:47 PM

Previous topic - Next topic

joesaliba

Devise = 18F26K22, but I am pretty sure rules apply to other.

I don't think I understood how TMR0 works.

If I opt to interrupt with INT0, will it take me to the ISR or it just add the 16bit counter I set for timer 0?

I would like that with every interrupt, it jumps to the ISR, where there, if INT0IF is set I will add a variable, and at the same time I increase the counter of timer0, so for after an x amount of time I see how many pulses I had. So, actually these will have two different values in them.

I can add another variable if needs be, but I would like to understand if it could be done.

The only time it takes me to the ISR is when timer0 overflows.

Regards

Joe


joesaliba

Ok,

I was doing a mistake. I thought that INT0 was RA4, which is T0CKI.

However, INT0 is RB0. A simple jumper solved the problem. Now a have TMR0 acting as a counter, clearing it when I want, and also have interrupt which will increase a variable to accumulate total counts.

Regards

Joe

trastikata

Hello,

How did you set-up the INT0 registers? Pay attention to the pulse edge. It's best if you can post how did you setup the interrupt registers and the interrupt handler, then we could give you more specific answers.

Regards

Pepe

#3
example of frequency meter made
for me with proteus simulation

joesaliba

Trastikata,

I was experimenting how I can combine an interrupt from a pin, in this case INT0, and increment counter in TMR0.

Well, tying RA4 and RB0 together did the trick. I can leave the TMR0 as a counter if need be.

Thanks Pepe for your your example.

Regards

Joe