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

Oscillating performance

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



Joined: 14 Feb 2020
Posts: 23

View user's profile Send private message

Oscillating performance
PostPosted: Sat Mar 13, 2021 7:37 am     Reply with quote

Configured these two microcontroller with practically the same parameters.
It is very simple programming.

With an oscilloscope I noticed a curious thing.

The 33FJ16GS504 oscillates twice the speed of the 33CH128MP506 with similar parameters.
Code:

#include <33CH128MP506.h>       
                                               
#use delay(crystal = 32 Mhz, clock= 64 MHz,restart_wdt)                                                   
#FUSES PR_PLL   
#FUSES CKSFSM   
#FUSES NOWDT                                                                       

#define    led_3     Pin_B13

void main(void)
{
   while(true)
   {
      output_toggle(led_3);
   }
}



Code:

////////////////////////////////////////////////////////////////////////////////////
#include <33FJ16GS504.h>                                                       

#use delay(crystal=40M, clock=64M, restart_wdt)
#FUSES PR_PLL                                                                 
#FUSES CKSFSM                                                         
#FUSES NOWDT                                                                             

#define  led_1       Pin_c5                                                     

void main()                                                                     
{
   while(true)
   {
     output_toggle(led_1);
   }   
}
temtronic



Joined: 01 Jul 2010
Posts: 9101
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Mar 13, 2021 8:25 am     Reply with quote

Might be a compiler bug ?
Different fuse settings ?
Get rid of the restart_wdt !
Ttelmah



Joined: 11 Mar 2010
Posts: 19217

View user's profile Send private message

PostPosted: Sat Mar 13, 2021 8:48 am     Reply with quote

First thing, get a magnifying glass and check the crystal really is 32M.
Most obvious thing that would cause this would be the crystal not actually
being the right frequency....
Then 'what compiler version'?.
Then I'd explicitly add the HS fuse. Possible the compiler is selecting XT
and the crystal is not being driven hard enough.
Then read the application note on the crystal oscillator. Check that the
crystal you have has the required parameters. Again running slow is
classic for a crystal that does not have enough gain. Sometimes a
parallel resistor helps here.
If you want to test the oscillator speed 'with an oscilloscope', you need
to specify the clock out pin is enabled, and test here, not on the
oscillator pins. The oscilloscope probe will often overload the oscillator.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Mar 13, 2021 12:53 pm     Reply with quote

Crystals normally only work up to about 27 MHz max, in fundamental mode.
So it's clear that you're running both crystals in 3rd overtone mode.
Based on your complaint, it's clear that one of them is running in
fundamental mode, against your intention.
Ttelmah



Joined: 11 Mar 2010
Posts: 19217

View user's profile Send private message

PostPosted: Sun Mar 14, 2021 3:23 am     Reply with quote

What is not 'clear' is whether the chip is running slow when the scope is not
present?. The scope probe itself could easily restrict the gain at the overtone
frequency and prevent operation here....
Generally insisting on running at the fundamental tends to happen if the
crystal is overdriven, or the capacitive loading is too high.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Mar 14, 2021 3:32 am     Reply with quote

You could be right. It bothers me that his program has no delay_ms()
statement in the loop. He couldn't see an LED toggling with that program.
Maybe he is just probing the crystal circuit and altering the oscillation.
Ttelmah



Joined: 11 Mar 2010
Posts: 19217

View user's profile Send private message

PostPosted: Sun Mar 14, 2021 3:40 am     Reply with quote

Absolutely.
The old simple delay_ms(1000) in the test loop would make it easy to know
how fast the chip is actually running.....
temtronic



Joined: 01 Jul 2010
Posts: 9101
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Mar 14, 2021 6:22 am     Reply with quote

Hopefully the scope probe is set to X10 to reduce it's 'loading ' effect on the PIC pin.
Ttelmah



Joined: 11 Mar 2010
Posts: 19217

View user's profile Send private message

PostPosted: Sun Mar 14, 2021 7:31 am     Reply with quote

and of course, testing on the OSCO pin, not OSCI.
ortegahernandes



Joined: 14 Feb 2020
Posts: 23

View user's profile Send private message

PostPosted: Wed Mar 17, 2021 5:22 am     Reply with quote

Thank you all for your comments.

Unfortunately, I won't have access to these two hardware anytime soon, as I'm on vacation.

However, I can say that in the most "slow" DSPiC, if I set timer 1, it works correctly. "1milliseconds"

Code:
setup_timer1(TMR_INTERNAL | TMR_DIV_BY_8, 4000);


The other one did not set the timer to compare.

as soon as I get back to work, after the holidays I test and come back here to post in this topic again.
Ttelmah



Joined: 11 Mar 2010
Posts: 19217

View user's profile Send private message

PostPosted: Wed Mar 17, 2021 7:54 am     Reply with quote

It sounds then as if it was probably the scope just loading the oscillator and
forcing it 'down'.....
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