Author Topic: PIC18F and CLKO on RA6: Output not working  (Read 3106 times)

0 Members and 1 Guest are viewing this topic.

Offline smoothVTerTopic starter

  • Regular Contributor
  • *
  • Posts: 145
  • Country: us
PIC18F and CLKO on RA6: Output not working
« on: December 12, 2016, 06:12:48 pm »
Hello,

Device:  PIC18F46J50 http://ww1.microchip.com/downloads/en/DeviceDoc/39931b.pdf

I'm using the Explorer 8 Discovery development board from Microchip, as well as the PIC18F46J50 plug-in module.   So far, everything has been working as expected.

I am interested in using the oscillator mode as described in this datasheet,  INTOSCPLLO   When this mode is chosen, the instruction clock is supposed to be output on pin RA6:





I am seeing no clock output at all from pin RA6 on the scope.   

What am I doing wrong?   Below is my code:


Code: [Select]
#include <xc.h>

// CONFIG2L
#pragma config OSC = INTOSCPLLO      // Oscillator (INTOSCPLLO (CLKO-RA6))
#pragma config T1DIG = OFF                 // T1OSCEN Enforcement (Secondary Oscillator clock source may not be selected)
#pragma config LPT1OSC = OFF             // Low-Power Timer1 Oscillator (High-power operation)
#pragma config FCMEN = OFF                // Fail-Safe Clock Monitor (Disabled)
#pragma config IESO = OFF                   // Internal External Oscillator Switch Over Mode (Disabled)


#BYTE REFOCON = getenv("SFR:REFOCON") // More portable;  show in Window->PIC memory views->SFR
#BIT   RODIV0  = REFOCON.0
#BIT   RODIV1 = REFOCON.1
#BIT   RODIV2 = REFOCON.2
#BIT   RODIV3 = REFOCON.3
#BIT   ROSEL  = REFOCON.4
#BIT   ROSSLP = REFOCON.5
#BIT   ROON   = REFOCON.7



void main(void)
{
    ROSEL = 0;                       // Use system clock as the base clock
    ROON  = 1;                       // Turn on reference clock output on RB2;  debugging to check if REFO = 8MHz;  it is
    TRISA = 0b00000000;     // Make sure RA6 is set as an output
    TRISB = 0b00000000;     // Make sure RB2 is set as an output
    while(1)
    {
         //nop here, nothing to do, just checking clock setups
    }
   
    return;
}





 

Offline voltsandjolts

  • Supporter
  • ****
  • Posts: 2302
  • Country: gb
Re: PIC18F and CLKO on RA6: Output not working
« Reply #1 on: December 12, 2016, 09:21:19 pm »
See Note 1 at the bottom of the picture you supplied. Maybe:

OSCTUNEbits.PLLEN = 1;

 

Offline smoothVTerTopic starter

  • Regular Contributor
  • *
  • Posts: 145
  • Country: us
Re: PIC18F and CLKO on RA6: Output not working
« Reply #2 on: December 12, 2016, 11:47:01 pm »
After setting this up correctly, still no output on RA6   for the CLKO ( RA6 ) pin. 

Ooops, yes, I must set PLLEN = 1 in order to enable the PLL.   That bit was missing from my code above, as well as the PLLDIV setting, which must be divide-by-2 in order to get a 4MHz input into the PLL. 



RA6 does not seem to be a PPS pin so I am still unclear as to why there is no CLKO output.   
« Last Edit: December 13, 2016, 02:55:27 am by smoothVTer »
 

Offline taustin

  • Contributor
  • Posts: 10
  • Country: us
Re: PIC18F and CLKO on RA6: Output not working
« Reply #3 on: December 28, 2016, 05:54:22 pm »
Is this working for you yet?

If the pin is also a shared analog input, try explicitly turning off the analog input. This has caught me and the students I work with many times. Analog input is turned on by default and even the most simple output test won't work.

Good Luck!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf