View previous topic :: View next topic |
Author |
Message |
ortegahernandes
Joined: 14 Feb 2020 Posts: 23
|
Oscillating performance |
Posted: Sat Mar 13, 2021 7:37 am |
|
|
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: 9229 Location: Greensville,Ontario
|
|
Posted: Sat Mar 13, 2021 8:25 am |
|
|
Might be a compiler bug ?
Different fuse settings ?
Get rid of the restart_wdt ! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19518
|
|
Posted: Sat Mar 13, 2021 8:48 am |
|
|
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
|
|
Posted: Sat Mar 13, 2021 12:53 pm |
|
|
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: 19518
|
|
Posted: Sun Mar 14, 2021 3:23 am |
|
|
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
|
|
Posted: Sun Mar 14, 2021 3:32 am |
|
|
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: 19518
|
|
Posted: Sun Mar 14, 2021 3:40 am |
|
|
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: 9229 Location: Greensville,Ontario
|
|
Posted: Sun Mar 14, 2021 6:22 am |
|
|
Hopefully the scope probe is set to X10 to reduce it's 'loading ' effect on the PIC pin. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19518
|
|
Posted: Sun Mar 14, 2021 7:31 am |
|
|
and of course, testing on the OSCO pin, not OSCI. |
|
|
ortegahernandes
Joined: 14 Feb 2020 Posts: 23
|
|
Posted: Wed Mar 17, 2021 5:22 am |
|
|
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: 19518
|
|
Posted: Wed Mar 17, 2021 7:54 am |
|
|
It sounds then as if it was probably the scope just loading the oscillator and
forcing it 'down'..... |
|
|
|