View previous topic :: View next topic |
Author |
Message |
dmitrboristuk
Joined: 26 Sep 2020 Posts: 55
|
PIC16F15375 timer0 |
Posted: Mon Nov 01, 2021 8:04 am |
|
|
Good day!
Please tell me how to connect the 24 or 32 MHz frequency to the Timer0 input. Is this possible in principle ?
Code: |
setup_oscillator ( OSC_HFINTRC_32MHZ
| OSC_CLK_DIV_BY_1
);
SETUP_NCO (
NCO_ENABLED
| NCO_ACTIVE_LOW
| NCO_PULSE_FREQ_MODE
| NCO_CLOCK_HFINTOSC // or NCO_CLOCK_FOSC
// | NCO_PULSE_WIDTH_2
| NCO_PULSE_WIDTH_128
,
514 );
|
The divider works great with NCO_CLOCK_HFINTOSC 1 and NCO_CLOCK_HFINTOSC output 15686 Hz
But on timer0, the input frequency is always 12 or 16 MHz
Code: |
setup_timer_0 (
T0_HFINTOSC
| T0_INPUT_NOT_SYNCRONIZED
| T0_DIV_1
| T0_8_BIT
,
var1
,
1 );
|
MCU PIC16F15375
Compiller 5.093
Conf. Words
Code: |
#fuses MCLR
#fuses PPS1WAY
#fuses LVP
#fuses RSTOSC_HFINTRC_PLL
|
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Mon Nov 01, 2021 8:45 am |
|
|
You can't.
Study the data sheet. Look at the Timer0 diagram. Look at the clock
sources. Fosc doesn't go to the timer. Only Fosc/4. |
|
|
dmitrboristuk
Joined: 26 Sep 2020 Posts: 55
|
|
Posted: Mon Nov 01, 2021 8:59 am |
|
|
Ok, thank you
011 = HFINTOSC with 2xPLL is 16 MHz? |
|
|
dmitrboristuk
Joined: 26 Sep 2020 Posts: 55
|
|
Posted: Mon Nov 01, 2021 9:48 am |
|
|
In datasheet PIC16(L)F15356/75/76/85/86 page 127 says that HFINTOSC generates frequencies of 1 ... 32 MHz, but 2xPLL is after it. Do I understand correctly that the actual frequencies of the HFINTOSC are 1 ... 16 MHz. That is, the maximum value of HFINTOSC that I can apply to the Timer0 input will be 16 MHz, even if 2xPLL is turned on. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Tue Nov 02, 2021 1:10 am |
|
|
Yes.
The point is not to look at the options after the HFINTOSC, but to look
at the peripheral you are dealing with.
The clock options are:
CLC1
SOSC
MFINTOSC
LFINTOSC
HFINTOSC
Fosc/4
T0CKI (via PPS).
None of these offer you a connection via the PLL's.
If you look at Figure 9-1 "SIMPLIFIED PICĀ® MCU CLOCK SOURCE BLOCK
DIAGRAM", you will see that the HFINTOSC, routes off to the peripherals
and _then_ to the PLL. The PLL can only be selected when this is being
used as the master oscillator. Not on any of the peripheral connections. |
|
|
dmitrboristuk
Joined: 26 Sep 2020 Posts: 55
|
|
Posted: Thu Nov 11, 2021 11:53 pm |
|
|
I have experimented with using an oscilloscope. I report that 32 MHz can be applied to timer0. But there are some limitations, apparently related to the physical capabilities of the microcontroller. At 32 MHz, the minimum value of the timer counter is 39. When you try to set the counter value less than 39, unstable, "ragged" pulses are output from the timer. Apparently for this reason I did not manage to do it the last time.
Here are some values: Frequency 32 MHz, prescaler 1: 1, counter value 39, timer output (via logic cell) 800 kHz
Frequency 16 MHz, prescaler 1: 1, counter value 19, at the output of the timer (through a logic cell) 800 kHz. Measurements at a temperature of 25 degrees. centigrade |
|
|
|