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 CCS Technical Support

How to enable Phase Locked Loop module in dsPic30F4011 ?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
small_chick



Joined: 17 Jul 2012
Posts: 53

View user's profile Send private message

How to enable Phase Locked Loop module in dsPic30F4011 ?
PostPosted: Fri Nov 02, 2012 9:48 am     Reply with quote

when i don't use this instruction "#fuses XT,NOWDT" and try to config directly through registers as the following function:
Code:
void Oscillator_Config()
{
        /*Oscillator Switching Sequence*/
   OSCCONH = 0x78;
   OSCCONH = 0x9A;
   OSCCONH = 0x03;
   
   OSCCONL = 0x46;
   OSCCONL = 0x57;
   OSCCONH = 0x01;
   
   while(OSWEN);
   /*Oscillator Mode is XT w/PLL 4x*/
   FOS1 = 1;
   FOS0 = 1;
   FPR3 = 0;
   FPR2 = 1;
   FPR1 = 1;
   FPR0 = 0;
   /*enable LP Oscillator*/
   LPOSCEN = 1;
   /*Oscillator Postscaler Selection = 1:1*/
   POST1 = 0;
   POST0 = 0;
   /*POR:Power-on reset timer's delay = 64 ms*/
   FPWRT1 = 1;
   FPWRT0 = 1;
   /*BOR:Minimum supply voltage = 4.2 (V)*/
   ORV1 = 0;
   ORV0 = 1;
   /*Disable Watchdog Timer*/
   FWDTEN = 0;
   SWDTEN = 0;
}

There's no clock for timer1 which is configurated as following:
Code:
void timers_init()
{
   /*initialize Timer1*/
   
   /*internal clock FOSC/4*/
   T1_TCS = 0;
   T1_TGATE = 0;
   
   PR1 = 0xFFFF;
   TMR1 = 0;
   /*Prescaler option = 1:256*/
   T1_TCKPS1 = 1;
   T1_TCKPS0 = 1;   
}

and

Code:
void interrupt_init()
{
   /*enable Timer1 interrupt*/
   T1IE = 1;      
   /*force Timer1 interrupt */
   T1IF = 1;
}

Code:

#include    <30F4011.h>
#include    "IO_module.c"
#include    "Interrupt_module.c"
#include   "Device_Configuration.c"
#include   "TimerX_module.c"
#fuses XT,NOWDT

#INT_TIMER1 NOCLEAR
void Timer1_ISR()
{
   T1IF = 0;
   T1_TON = 1;
   RB0 ^= 1;
}

void main()
{
   Oscillator_Config();
   port_init();
   timers_init();
   interrupt_init();
   while(1);
}


Code:

void port_init()
{
   /*PORTB*/
   TRISB &= ~BIT0;
   PORTB = 0xFFFF;
   ADPCFG = 0xFFFF;//config all ANx as digital    
}

Hoping someone can help me solve this problem ? Very Happy
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion 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