Author Topic: PIC16F883 internal oscillator  (Read 4004 times)

0 Members and 1 Guest are viewing this topic.

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
PIC16F883 internal oscillator
« on: October 18, 2014, 07:38:08 am »
Trying now almost a whole day to get the internal oscillator of the PIC16F883 working correctly...

Regardless of the _CONFIG1 settings and OSCCON programming, the CLKOUT is always 32kHz/4....

Did I miss something during initialisation?


Code: [Select]
__CONFIG _CONFIG1, _INTOSC & _WDT_OFF & _LVP_OFF


org 0; start code at 0

Start:
    BANKSEL OSCCON
    BSF     OSCCON,IRCF2
    BSF     OSCCON,IRCF1
    BSF     OSCCON,IRCF0
    BSF     OSCCON,SCS
    MOVWF   OSCCON
    ...
    ...
 

Offline David_AVD

  • Super Contributor
  • ***
  • Posts: 2806
  • Country: au
Re: PIC16F883 internal oscillator
« Reply #1 on: October 18, 2014, 07:49:02 am »
Why are you settings some bits in OSCCON then moving W (some unknown value) into OSCCON overwriting it?
 

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Re: PIC16F883 internal oscillator
« Reply #2 on: October 18, 2014, 08:35:47 am »
Jesus...I must be still really tired this morning ;-)

The MOVWF is some leftover when I set the value with an advance MOVLW statement....but didn't succeed yesterday...
Maybe also to do that the PIC16F883 requires indeed the PGM pin been tied low during programming via a resistor....

Now to the next problem why I can't display anything on the HDSP-2111 module...same code which works on PIC18F4550 (besides different ports)..


* davorin grabs some more coffee (o;
 

Offline David_AVD

  • Super Contributor
  • ***
  • Posts: 2806
  • Country: au
Re: PIC16F883 internal oscillator
« Reply #3 on: October 18, 2014, 08:45:00 am »
Port related issues are often the result of not disabling a peripheral (A2D, comparator, etc) that shares the port and has a higher priority.
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3240
  • Country: gb
Re: PIC16F883 internal oscillator
« Reply #4 on: October 18, 2014, 10:43:07 am »
Port related issues are often the result of not disabling a peripheral (A2D, comparator, etc) that shares the port and has a higher priority.

Also the 14 bit core devices are prone to read-modify-write issues if you perform bitwise operations on the ports, which isn't a problem on the 18F devices if you use the LATx registers.
 

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Re: PIC16F883 internal oscillator
« Reply #5 on: October 18, 2014, 01:08:34 pm »
Ports are all working normally (o;

But what I see is a high jitter on the CLKOUT pin....internal clock set to 4MHz....so output is 1MHz

Anyone can explain why the internal oscillator drifts off badly and comes back to 1MHz?

Nothing done in the code...just OSCCON/PORT initialisation and then an endless loop doing nothing...

Power supply is fine...HP 6632B...and no noise on the VCC rail....

 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: PIC16F883 internal oscillator
« Reply #6 on: October 18, 2014, 01:28:48 pm »
Quote
Anyone can explain why the internal oscillator drifts off badly and comes back to 1MHz?

Nature of the beast that is a relaxation oscillator.

It is also why it is very useful for generating random numbers.
================================
https://dannyelectronics.wordpress.com/
 

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Re: PIC16F883 internal oscillator
« Reply #7 on: October 18, 2014, 01:31:27 pm »
Adding more capacitors helped a little.....but still see jitter on CLKOUT....

Interestingly setting voltage down to 4V stops it completely....

Hmm..when I remove the HDSP-2111 LED display....clock is rock solid....
 

Offline David_AVD

  • Super Contributor
  • ***
  • Posts: 2806
  • Country: au
Re: PIC16F883 internal oscillator
« Reply #8 on: October 19, 2014, 12:43:52 am »
Sounds like insufficient decoupling on the PIC Vdd pin(s).  They need to be nice and close to the chip.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: PIC16F883 internal oscillator
« Reply #9 on: October 19, 2014, 01:11:26 pm »
Quote
clock is rock solid...

I guess what's "rock solid" is relative: rc oscillators are known to exhibit large phase noise, which makes them quite useful in some applications.
================================
https://dannyelectronics.wordpress.com/
 

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Re: PIC16F883 internal oscillator
« Reply #10 on: October 19, 2014, 01:32:58 pm »
It's not the RC oscillator...when you choose a frequency above 32kHz, the quartz is used instead...

And yes...decoupling is an issue here, especially with the HDSP-2111 current peaks...but not easy to handle on a breadboard (o;


At least the DCF77 code from a 16F628 runs nicely now.....just needed to compare the UTC messages with a DCF77 reference ;-)


 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf