CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug Reports on this forum. Send them to support@ccsinfo.com

[How to] Pic24EP256 output Crystal or FPLLO freq. on a pin

 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
pieter



Joined: 16 Jan 2011
Posts: 27

View user's profile Send private message

[How to] Pic24EP256 output Crystal or FPLLO freq. on a pin
PostPosted: Thu Mar 13, 2014 11:51 pm     Reply with quote

Code:

//  Manual Setup for Reference Clock Output
#include <C:\Program Files\PICC\Devices\24EP256GP204.h>
#device ADC=12
#FUSES WDT                       //Watch Dog Timer
#FUSES NOIESO                   //Internal External Switch Over mode disabled
#FUSES PLLWAIT                   //Use when PLL ready
#FUSES HS
#FUSES PR_PLL                     //Pimary oscillator
#FUSES OSCIO                       //OSC2 is general purpose output
#FUSES WPRES128              //Watch Dog Timer PreScalar 1:128
#FUSES WPOSTS16              //Watch Dog Timer PostScalar 1:32768
#use delay(clock = 128000000, crystal=8000000, RESTART_WDT)
#PRAGMA   ZERO_RAM
#use fast_io(A)
#use fast_io(B)
#use fast_io(C)
//
#word      REFOCON=0x074E               // reference clock setup register
#word      RP56=0x068C                  // Pin C8 reprogrammable address
//
//**********************************************************************************
//
main()
{
   SET_TRIS_A(0xfb7f);   // 1111 1011 0111 1111  my settings
   SET_TRIS_B(0x041f);   // 0000 0100 0001 1111
   SET_TRIS_C(0xfc03);   // 1111 1100 0000 0011  pin C8 is output
   Output_A(0x0000);   //0b7f);
   Output_B(0x0000);   //041f);
   Output_C(0x0143);   //0143);
//
//   With the fuses above:
//   Crystal = 8 mHz
//   Pll multiplies clock to 128 mHz
//   Output the CRYSTAL frequency or the FPLLO clock on Pin C8:
//
//   REFOCON=0x3700;            // CRYSTAL frequency to output as ref frequency registers div128
//   REFOCON=0xB700;            // measure freq on pin C8 with scope and multiply with 128 to get the crystal freq.
//     or
   REFOCON=0x2C00;            // FPLLO clock  div4096
   REFOCON=0xAC00;            // measure freq on pin C8 with scope and multiply with 4096 to get the FPLLO freq.
   RP56=0x31;                  // set reference clock output on pin C8
//
   while (TRUE)                  // main routine
   {
      RESTART_WDT();            // reset watchdog
      delay_ms(500);
   }
}
Fonky



Joined: 19 Oct 2014
Posts: 1

View user's profile Send private message

PostPosted: Sun Oct 19, 2014 10:33 am     Reply with quote

/ With the fuses above:
// Crystal = 8 mHz
// Pll multiplies clock to 128 mHz
// Output the CRYSTAL frequency or the FPLLO clock on Pin C8:
//
// REFOCON=0x3700; // CRYSTAL frequency to output as ref frequency registers div128
// REFOCON=0xB700; // measure freq on pin C8 with scope and multiply with 128 to get the crystal freq.
// or
REFOCON=0x2C00; // FPLLO clock div4096
REFOCON=0xAC00; // measure freq on pin C8 with scope and multiply with 4096 to get the FPLLO freq.
RP56=0x31; // set reference clock output on pin C8
//
while (TRUE) // main routine
{
RESTART_WDT(); // reset watchdog
delay_ms(500);
_________________
Kick
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group