Page 1 of 1

PIC16F1788 Clock?

Posted: Mon Oct 22, 2018 9:27 am
by seokgi
Hello!
I am trying to program using PIC16F1788. But the clock seems to be out of place. I've tried a couple of things, but it does not seem to work.
Can you help me? I send my test program.

Thank you.

Re: PIC16F1788 Clock?

Posted: Mon Oct 22, 2018 9:30 am
by seokgi
My program

Re: PIC16F1788 Clock?

Posted: Mon Oct 22, 2018 10:02 am
by Benj
Hello.

It looks like you might need this line of C code at the start of your program to configure the internal oscillator to 32MHz.

Code: Select all

OSCCON = 0xF0;
For future reference the INTOSC helper component available from the Tools component toolbar helps to setup internal oscillator options.

Re: PIC16F1788 Clock?

Posted: Mon Oct 22, 2018 10:05 am
by medelec35
Hi seokgi,
Your code is missing a C Code block with an OSCCON value at the very start of your program.
The OSCCON=0xXX value sets the speed of internal oscillator.
Without the OSCCON value set, the internal oscillator will run at the default value.
Looking at the datasheet on page 86,its 500KHz:
Internal osc.png
(49.71 KiB) Downloaded 1475 times
That's why your hardware is not running correctly.
The easiest way to obtain the correct value is on your flowchart, go to tools and Add IntOsc Helper to your panel.
Right-click the INT OSC Icon on the panel and select properties.
Change the Oscillator Speed to 32000000
The Code will contain the word OSCCON and the value along with a semicolon.
Click on the generated value so it's all highlighted.
Right-click Copy.
Add a C code block to the very top of Main so it's always the first thing that's accessed.
Within the C Code block, right-click and select paste.
Now recompile and see if the clock is running at the correct speed.

Edit:
Whoops, Ben beat me to it, but as it took a little while for me to type, will leave the post in.

Re: PIC16F1788 Clock?

Posted: Tue Oct 23, 2018 2:08 am
by seokgi
It was resolved.
thank you very much.
I am very adorable in FC.

Thank you MATRIX.