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

Problem PLL and RS232 on dsPIC33FJ256MC710

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



Joined: 05 Aug 2010
Posts: 5
Location: UK

View user's profile Send private message

Problem PLL and RS232 on dsPIC33FJ256MC710
PostPosted: Thu Aug 05, 2010 8:09 am     Reply with quote

Dear all,
I am a new user on dsPIC33Fxxxx. I use dsPIC33Fj256MC710 with RS232 and my code is shown below. This code can normally operate with 8MHz crystal.
Code:

#include <33FJ256MC710.h>
#fuses XT,PR,NOWDT,NOCOE,NODEBUG, NOWRTB, NOPUT, NOWRTSS, NOWRT, NOPROTECT, NORSS
#use delay(clock=8M)
#use rs232(baud=9600,uart1)

void main(void)
{
  while(TRUE)
 {
    printf("Test dsPIC33F RS232 \n");
   delay_ms(3000);
 }
}

But now I need to use PR_PLL to increase speed of cpu to 40 MIPs.
I have set the parameters as shown below. I cannot send data to RS232.
Code:

#include <33FJ256MC710.h>
#fuses XT,PR_PLL,NOWDT,NOCOE,NODEBUG, NOWRTB, NOPUT, NOWRTSS, NOWRT, NOPROTECT, NORSS
#use delay(clock=40M)
#use rs232(baud=9600,uart1)

void main(void)
{
  while(TRUE)
 {
    printf("Test dsPIC33F RS232 \n");
   delay_ms(3000);
 }
}

I have aready read this topic and tried but it doesn't work.
https://www.ccsinfo.com/forum/viewtopic.php?t=38529&highlight=dspic33fj256gp710

This is my code.
Code:


#include <33FJ256MC710.h>

#fuses XT,PR_PLL,NOWDT,NOCOE,NODEBUG, NOWRTB, NOPUT, NOWRTSS, NOWRT, NOPROTECT, NORSS
#use delay(clock=40M)
#use rs232(baud=9600,uart1) // rcv=PIN_F2, xmit=PIN_F3)

#word OSCCON   = 0X0742 //OSCILLATOR CONTROL REGISTER
#word CLKDIV   = 0X0744 //CLOCK DIVISOR REGISTER
#word PLLFBD   = 0X0746//PLL FEEDBACK DIVISOR REGISTER

#bit CLKDIV0=CLKDIV.0//‘N1’, PLL prescaler ->N1=2
#bit CLKDIV1=CLKDIV.1
#bit CLKDIV2=CLKDIV.2
#bit CLKDIV3=CLKDIV.3
#bit CLKDIV6=CLKDIV.6//‘N2’, PLL prescaler ->N2=2
#bit CLKDIV7=CLKDIV.7
#bit CLKDIV11=CLKDIV.11//DOZE Mode Enable bit
#bit CLKDIV12=CLKDIV.12//Processor Clock Reduction Select bits->1:1
#bit CLKDIV13=CLKDIV.13
#bit CLKDIV14=CLKDIV.14

#bit OSCCON8=OSCCON.8
#bit OSCCON9=OSCCON.9
#bit OSCCON10=OSCCON.10


void main(void)
{
 /*************************************************************
  Second Modify this registers to custom value in main():
 *************************************************************/
CLKDIV0=0;//‘N1’, PLL prescaler ->N1=2
CLKDIV1=0;
CLKDIV2=0;
CLKDIV3=0;
CLKDIV6=0;//‘N2’, PLL prescaler ->N2=2
CLKDIV7=0;
CLKDIV11=1;//DOZE Mode Enable bit
CLKDIV12=0;//Processor Clock Reduction Select bits->1:1
CLKDIV13=0;
CLKDIV14=0;
OSCCON8=1;//Primary oscillator (XT, HS, EC) with PLL
OSCCON9=1;
OSCCON10=0;

//PLLFBD=0b000011110;//‘M’, PLL multiplier->M=32
PLLFBD=0b000101000;//‘M’, PLL multiplier->M=40
  while(TRUE)
 {
    printf("Test dsPIC33F RS232 \n");
   delay_ms(3000);
   
 }
}

I'm not sure, am I doing something wrong? Anyone please advise me.
Thank you in advance.
Ttelmah



Joined: 11 Mar 2010
Posts: 19338

View user's profile Send private message

PostPosted: Thu Aug 05, 2010 10:04 am     Reply with quote

You need to unlock the clock register, to set the configuration bits yourself. If I remember correctly, Fvm, has posted details of how to do this in the past. A search may find it.
The settings you are making will be ignored otherwise.
What version compiler are you on?.
The command:
#use delay(crystal=8000000,clock=40000000)
Should work now, but didn't till recently. What version compiler are you using?.

Best Wishes
bionicbot



Joined: 05 Aug 2010
Posts: 5
Location: UK

View user's profile Send private message

PostPosted: Thu Aug 05, 2010 10:28 am     Reply with quote

Thank you very much Ttelmah. I used #use delay(crystal=8000000,clock=40000000) as you recommended. RS232 works good but I will check the real speed by using oscilloscope again
Thank you again.
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