Created Wed, 19 Jun 2013 16:56:44 +0000 by caroper
Wed, 19 Jun 2013 16:56:44 +0000
I want to output the Reference clock on a ChipKIT but the statement: REFOCON.OE = 1;
is returning an error of: BB32_PPS.cpp: In function 'void setup()': BB32_PPS.cpp:26:13: error: request for member 'OE' in 'REFOCON', which is of non-class type 'volatile uint32_t'
Is there any way to enable the Reference Clock output without having to modify the Bootloader itself?
Cheers Chris
Wed, 19 Jun 2013 17:36:20 +0000
Try REFOCONbits.OE instead...
Wed, 19 Jun 2013 19:13:36 +0000
Thanks :)
That solved the Compiler error, but I am still not seeing the clock.
I must have an error in my logic. Back to reading the Datasheet.
Cheers, Chris
Wed, 19 Jun 2013 19:54:03 +0000
It must have been a long day, I am sure I am overlooking something simple. Can any one see an obvious error in this code?
It compiles and runs fine, but I am getting nothing on the REFCLKO Pin.
//_________________________________________________________________
//
// BB32_PPS.pde
//
// C.A.Roper - 2013/07/19
//
// An example of using PPS PIN mapping on the ChipKIT BB32
// Outputs the System Clock on ChipKIT PIN# 6 (RB13)
//_________________________________________________________________
//
#include <plib.h>
#define GREEN_LED 13
#define RED_LED 14
#define REFCLKOut 6
void setup()
{
pinMode(RED_LED, OUTPUT);
pinMode(GREEN_LED, OUTPUT);
pinMode(REFCLKOut, OUTPUT); // System Clock Output
if(mapPps(REFCLKOut, PPS_OUT_REFCLKO))
{
REFOCONbits.OE = 1; // EN System Clock Output
digitalWrite(GREEN_LED, HIGH); // Mapping OK
}
else digitalWrite(RED_LED, HIGH); // Mapping FAILED
}
void loop()
{
}
Cheers Chris
Thu, 20 Jun 2013 11:49:16 +0000
Did you try setting the other registers to make sure that you have the right source and division set up? I'm not sure if there is anything set (or why there would be) in the initialization but you may want to specifically set all of the registers that affect the clock output.
Best of luck,
Jason[attachment=0]REFOUT block.JPG[/attachment]
Thu, 20 Jun 2013 12:45:59 +0000
Did you try setting the other registers to make sure that you have the right source and division set up?
Thanks Jason,
That did it,
You made me look at the Oscillator Module again from a new angle. I had not realised that it had a separate PLL and Mux just for the Reference Clock output. I had blindly assumed it would output the SYSCLK.
Now I am even more impressed with the architecture of the PIC32MX family and realise that I need to study each module in detail, not just make assumptions.
Here is the modified Sketch that makes the POSC available on on PIN 6. I am reading 7.996Mhz with an 8Mhz Xtal, so certainly acceptable.
//_________________________________________________________________
//
// BB32_PPS.pde
//
// C.A.Roper - 2013/07/19
//
// An example of using PPS PIN mapping on the ChipKIT BB32
// Outputs the System Clock on ChipKIT PIN# 6 (RB13)
//_________________________________________________________________
//
#include <plib.h>
#define GREEN_LED 13
#define RED_LED 14
#define REFCLKOut 6
void setup()
{
pinMode(RED_LED, OUTPUT);
pinMode(GREEN_LED, OUTPUT);
pinMode(REFCLKOut, OUTPUT); // System Clock Output
if(mapPps(REFCLKOut, PPS_OUT_REFCLKO))
{
REFOCONbits.ROSEL = 2; // Reference Clock Source Select POSC
REFOCONbits.ON = 1; // Reference Oscillator Module enabled
REFOCONbits.OE = 1; // Reference clock is driven out on REFCLKO pin
digitalWrite(GREEN_LED, HIGH); // Mapping OK
}
else digitalWrite(RED_LED, HIGH); // Mapping FAILED
}
void loop()
{
}
Thanks again, Cheers Chris
Thu, 20 Jun 2013 13:13:49 +0000
Chris,
Glad I could inspire new thought. I've been there before with other modules I've tried to use for the first time, and found anytime I'm trying a new module I need to be very intimate with the block to understand all of the configurations. It seems complicated, but when comparing to other processors I have come to appreciate the flexibility it allows for.
Glad to hear that you are enjoying the PIC32.
Jason