Internal Oscillator

From Flowcode Help
Jump to navigationJump to search

A lot of the devices have an inbuilt oscillator which can be used to reduce the number of devices required to drive the microcontroller.

The device datasheet should detail the type of oscillator available to the device.

To control the internal oscillator speed, a c code block will require adding at the very top of main, so its the first icon to be accessed.

Luckily, we don't need to dive into the datasheet to work out the code to set the internal oscillator to the correct speed.

The is an Internal Oscillator Helper component which is located in Components Libraries > Matrix Tools > IntOsc Helper Alternatively, Use the search magnifying glass option.

This can be found on left of the Components Libraries and enter intos in the search bar.

InOscHelper1.png

Setting the hardware at the correct speed for PIC16F18877

1. Build > Project Options... Other options > Clock speed (MHZ) [defines delay-related timings] & enter desired speed, e.g. 16MHz. This does not set the hardware speed, but it's required step. The Configure settings must also be correct.

E.g External Oscillator > Oscillator Off

Software Oscillator > HFINTOSC 32MHz

2. Add IntOsc Helper to the 2D panel, right-click on the IntOsc Helper component and select properties.

3. Enter the required speed in Hz e.g 1600000

4. Copy the full contents next to the code window (OSCFRQ = 0x05;)

5. add a C code command icon at the top of Main and paste the code that was copied in step 4

InOscHelper2.png

The internal osc should now be set at 16NHz, assuming all the configuration settings are correct.

You should be aware that other target device use OSCCON instead of OSCFRQ, but the IntOsc Helper allows for that.


A One second LED flasher test can be very useful to confirm if your device is actually running at the intended speed.