Example for simple Timer2 timebase setup on PIC18F46K42
for days now, I'm trying to figure out how to setup Timer2 as a simple timebase for the I2C module (TMR2 postscaled output).
I'm using a PIC18F46K42 with HFINTOSC at 4MHz (MPLAB X v5.15 , XC8 v2.05 and MCC v3.75).
Reading the datasheet there are so many options for external clock and reset sources but nothing how to manage a simple timebase.
So I tried using MCC and first selected 'Roll over puls' as control mode, as the other modes sound to be single shot only.
The 'Start/Reset option' shows 'Software control' as the only option, that doesn't require and external reset pin.
Does 'Software control' mean, I have to add a special reset code, and then how or when or where should it be executed?
Clock source is FOSC/4 and timer period is set to 100us.
Looking at the registers, T2RST is set to 0x0. The datasheet says that reset source is now 'Pin selected by T2INPPS' and the PinManager show a T2IN pin to be selected.
But the 'Start/Reset option' is set as 'Software control' with no external pin ....very confusing!!
Actually, as I have expected, that configuration doesn't work.
So it seems I'm missing something basic. Mostly some not so much confusing documentation.
I'd really be glad, if anybody could give a simple setup (MCC or c-code) or a non confusing explanation how Timer2 could be used as 'TMR2 postscaled output'.