User Tools

Site Tools


pic16f1455_oscillators

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
pic16f1455_oscillators [2019/10/04 18:59]
60.240.96.191 created
pic16f1455_oscillators [2021/02/02 01:24] (current)
Line 11: Line 11:
 So let's start out.  So let's start out. 
  
-I'll cut straight to the answer; the default clock frequency on the PIC16F1455 is 500kHz. This frequency comes from the High Frequency Internal Oscillator or (HFINTOSC). There is no PLL no achieve this frequency (more on this later).+I'll cut straight to the answer; the default clock frequency on the PIC16F1455 is 500kHz. This frequency comes from the High Frequency Internal Oscillator or (HFINTOSC). There is no PLL to achieve this frequency (more on this later).
  
 Page 73 of the [[http://​ww1.microchip.com/​downloads/​en/​DeviceDoc/​40001639B.pdf|datasheet]] tells us that 500kHz is the "​default upon Reset"​. So that is the default power-on frequency of the PIC16F1455. Page 73 of the [[http://​ww1.microchip.com/​downloads/​en/​DeviceDoc/​40001639B.pdf|datasheet]] tells us that 500kHz is the "​default upon Reset"​. So that is the default power-on frequency of the PIC16F1455.
  
-If you need a basic breadboard wiring diagram for the PIC16F1455, you can check the previous article.+If you need a basic breadboard wiring diagram for the PIC16F1455, you can check the [[pic16f1455|previous article]].
  
  
Line 26: Line 26:
  
 ===== Using the internal oscillator ===== ===== Using the internal oscillator =====
-Rather than use an external oscillator, use the internal one. There are two way to do this. You can either declare this at the top of your code with:+Rather than use an external oscillator, use the internal one. There are two ways to do this. You can either declare this at the top of your code with:
  
   #pragma config FOSC = INTOSC ​   // INTOSC = Internal Oscillator   #pragma config FOSC = INTOSC ​   // INTOSC = Internal Oscillator
Line 63: Line 63:
  
 The on and off will be accurately changing every second, thanks to ensuring that ''​_XTAL_FREQ''​ matches the frequency chosen with the ''​IRCF''​ bits in the ''​OSCCON''​ register. The on and off will be accurately changing every second, thanks to ensuring that ''​_XTAL_FREQ''​ matches the frequency chosen with the ''​IRCF''​ bits in the ''​OSCCON''​ register.
 +
 +If you're observant, you may notice that the blinking interval is not exactly one second. I'll cover why shortly.
  
 ===== Using PLL to achieve 24MHz ===== ===== Using PLL to achieve 24MHz =====
Line 101: Line 103:
  
 The datasheet does not list what the default for clock division is when resetting a PIC. However, the default in the configuration bits is shown as: ''​CLKDIV6''​ (using the MPLAB X IDE). Which means to divide the CPU clock by six. Or... make the CPU a sixth the normal speed. The datasheet does not list what the default for clock division is when resetting a PIC. However, the default in the configuration bits is shown as: ''​CLKDIV6''​ (using the MPLAB X IDE). Which means to divide the CPU clock by six. Or... make the CPU a sixth the normal speed.
 +
 +And this is why the interval was not quite correct when we were setting the 62.5kHz frequency in the previous section. It was because there was some CLKDIV dividing set.
  
 ===== Low Frequency Internal Oscillator (LFINTOSC) ===== ===== Low Frequency Internal Oscillator (LFINTOSC) =====
Line 139: Line 143:
  
   #define _XTAL_FREQ 17664000UL //17.664MHz   #define _XTAL_FREQ 17664000UL //17.664MHz
 +
 +Ensure the PLL is off to ensure good timing:
 +
 +  #pragma config PLLEN = 0 //Turn off PLL
  
 And finally, the only ''​OSCCON''​ register setting you need is: And finally, the only ''​OSCCON''​ register setting you need is:
pic16f1455_oscillators.1570215598.txt.gz ยท Last modified: 2021/02/02 01:24 (external edit)