small_chick
Joined: 17 Jul 2012 Posts: 53
|
How to enable Phase Locked Loop module in dsPic30F4011 ? |
Posted: Fri Nov 02, 2012 9:48 am |
|
|
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 ? |
|