| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		
			MCUprogrammer
 
 
  Joined: 08 Sep 2020 Posts: 233
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				| dsPIC30F3014 using PLL | 
			 
			
				 Posted: Mon Jan 09, 2023 4:59 am     | 
				     | 
			 
			
				
  | 
			 
			
				CCS C 5.113
 
 
 
Hi
 
How many MHz crystals on the dsPIC30F3014 processor can I clock at 120MHz?
 
e.g;
 
#use delay(clock = 120MHz,crystal=20MHZ) gives an error.
 
How will I do.
 
 
I see that the processor is crashing during operation. When I cut off the power and put it back on, the problem goes away. Is that why it locks because I'm using an internal oscillator? What would you recommend to fix this situation?
 
The locked processor is the dsPIC33EV series processor. _________________ Best Regards...
 
MCUprogrammer
 
_______________________________
 
Work Hard | 
			 
		  | 
	
	
		  | 
	
	
		
			Ttelmah
 
 
  Joined: 11 Mar 2010 Posts: 19967
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Mon Jan 09, 2023 5:36 am     | 
				     | 
			 
			
				
  | 
			 
			
				120MHz can't be generated from a 10MHz crystal.
 
 
120/4 = 30
 
120/8 = 15
 
120/16 = 7.5
 
 
Then you can use this *1, *2 or *3 (up to the 25MHz max). Or an external 
 
oscillator.
 
 
So you need a 7.5Mhz, 15Mhz, or 22.5Mhz crystal to actually get to 120Mhz.
 
 
On your 33EV, sounds like an interference or supply problem. Or possibly
 
something silly like overrunning the stack. Check what the listing file
 
says the stack size needs to be (remember size is 2* the size given). | 
			 
		  | 
	
	
		  | 
	
	
		
			MCUprogrammer
 
 
  Joined: 08 Sep 2020 Posts: 233
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Mon Jan 09, 2023 6:11 am     | 
				     | 
			 
			
				
  | 
			 
			
				I have a 24MHz or 25MHZ crystal. Are these useless?
 
 
I don't understand exactly what you want to say here.
 
 
"something silly like overrunning the stack. Check what the listing file
 
says the stack size needs to be (remember size is 2* the size given). _________________ Best Regards...
 
MCUprogrammer
 
_______________________________
 
Work Hard | 
			 
		  | 
	
	
		  | 
	
	
		
			MCUprogrammer
 
 
  Joined: 08 Sep 2020 Posts: 233
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Mon Jan 09, 2023 6:33 am     | 
				     | 
			 
			
				
  | 
			 
			
				Is this the event you're talking about?
 
 
 	  | Code: | 	 		  
 
 ROM used:   1472 bytes (1%)
 
                           Largest free fragment is 65536
 
               RAM used:   143 (1%) at main() level
 
                           146 (1%) worst case
 
               Stack used: 42 locations (4 in main + 38 for interrupts)
 
               Stack size: 128
 
 | 	 
  _________________ Best Regards...
 
MCUprogrammer
 
_______________________________
 
Work Hard | 
			 
		  | 
	
	
		  | 
	
	
		
			temtronic
 
 
  Joined: 01 Jul 2010 Posts: 9589 Location: Greensville,Ontario 
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Mon Jan 09, 2023 7:12 am     | 
				     | 
			 
			
				
  | 
			 
			
				I was curious about the 'clock configuration,so I downloaded the datasheet.
 
 
Using table 20-1..
 
a 25 MHz xtal can be divided by 2 or /3 THEN PLL will multiply by x4,x8 or x16
 
 
25/2=12.5   x4 = 50MHZ, x8=100MHz, x16= 200 MHz
 
 
25/3=8.33   x4=33, x8=66 ,x16=132
 
 
so the fastest legal speed using 25MHz xtal is 100 MHz
 
 
In the good old days ,I'd cut a QB45 program to figure all this out,but alas can't run it on a modern PC so....my numbers were done with paper and pencil.
 
There's probably a fancy spreadsheet or 'ap' you can get off the web to do the 'math'.
 
 
BTW be very careful with PCB traces and layout ! Running any micro at very high speeds MUST have well designed PCB and CLEAN. Also have LOTS of proper 'decoupling' caps. | 
			 
		  | 
	
	
		  | 
	
	
		
			MCUprogrammer
 
 
  Joined: 08 Sep 2020 Posts: 233
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Mon Jan 09, 2023 7:45 am     | 
				     | 
			 
			
				
  | 
			 
			
				So, am I going to do that splitting?
 
  Or is it enough to write the following code?
 
#fuses HS3_PLL8    //High Speed Crystal osc (10-25MHz) divide by 3 with 8X PLL
 
#use delay(clock=100MHZ) _________________ Best Regards...
 
MCUprogrammer
 
_______________________________
 
Work Hard | 
			 
		  | 
	
	
		  | 
	
	
		
			temtronic
 
 
  Joined: 01 Jul 2010 Posts: 9589 Location: Greensville,Ontario 
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Mon Jan 09, 2023 8:41 am     | 
				     | 
			 
			
				
  | 
			 
			
				I don't think that will work....
 
25 /3   x8 = 66MHz, so 'clock=100M' cannot compute.
 
 
I'd see if there's an example program in CCS or on this forum....
 
I don't have that PIC so hopefully others will reply.
 
pretty sure it has a max speed of 120 MHz,so you need to 'work back' to see what combination of xtal divider and PLL setup works for you. | 
			 
		  | 
	
	
		  | 
	
	
		
			Ttelmah
 
 
  Joined: 11 Mar 2010 Posts: 19967
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Mon Jan 09, 2023 8:54 am     | 
				     | 
			 
			
				
  | 
			 
			
				Your original clock line does all the settings for you. The point is though
 
that the frequency you ask for has to be one that can be done with your
 
crystal. 
 
With the 10MHz, you can do 80MHz.
 
With the 25Mhz, you can do 100MHz. 
 
With the 24MHz, you can do 96hz.
 
 
I think the middle one is going to be the one for you. 
 
 
So:
 
 
#use delay(clock=100MHz,crystal=25MHz)
 
 
Will merrily compile/work.
 
 
If you must have 120MHz, then you need to buy a compatible crystal.
 
 
Your stack looks OK. A little tight (I usually work on needing at least 10% 
 
free, since extra stack is used when debugging). 
 
You don't say what compiler version?. There was an issue a few versions
 
ago, with certain maths overflows crashing the system (in the known
 
faults forum). 
 
If it isn't a version with that problem, then you need to be looking at 
 
an electrical problem. | 
			 
		  | 
	
	
		  | 
	
	
		
			temtronic
 
 
  Joined: 01 Jul 2010 Posts: 9589 Location: Greensville,Ontario 
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Mon Jan 09, 2023 9:06 am     | 
				     | 
			 
			
				
  | 
			 
			
				re: 96hz. 
 
 
hehehe...Sure glad I'm not the only one with fat fingers ! I KNOW it's a typo, after all it is Monday again....well here anyway.
 
 
Crazy thing is my Energy control system panels used a 24 Hz clock, yes Twenty four hertz, for the serial communication lines that went up to 15 miles away. | 
			 
		  | 
	
	
		  | 
	
	
		
			MCUprogrammer
 
 
  Joined: 08 Sep 2020 Posts: 233
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Mon Jan 09, 2023 9:08 am     | 
				     | 
			 
			
				
  | 
			 
			
				thank you for the replies. I wrote the compiler version in the beginning. I guess you didn't notice. I am using version 5.113.
 
 
Could I be having a locking problem because I'm using an internal oscillator?
 
- I pulled down all the empty pins that I didn't use with 4K7.
 
- Since I did not use OSC1 and OSC2 crystal pins, I did pulldown with 4k7. _________________ Best Regards...
 
MCUprogrammer
 
_______________________________
 
Work Hard | 
			 
		  | 
	
	
		  | 
	
	
		
			Ttelmah
 
 
  Joined: 11 Mar 2010 Posts: 19967
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Mon Jan 09, 2023 9:14 am     | 
				     | 
			 
			
				
  | 
			 
			
				Almost certainly not because of the internal oscillator, unless there is
 
some timing event (for example you could easily get a framing error
 
on serial I/O with the internal OSC, and if this is not handled this could
 
cause a problem).
 
Have you got the brownout enabled on the chip?. 
 
 
I quite commonly miss things in what I type. I tend to be doing other 
 
things at the same time, and with three computer screens, a couple of
 
keyboards and mice, it is easy to miss a character...
 
 
It was not plain from your post that the code in the EV processor was
 
using the current compiler. Could easily be older code showing the issue. | 
			 
		  | 
	
	
		  | 
	
	
		
			MCUprogrammer
 
 
  Joined: 08 Sep 2020 Posts: 233
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Mon Jan 09, 2023 9:19 am     | 
				     | 
			 
			
				
  | 
			 
			
				#use delay(clock=100MHz,crystal=25MHz)
 
I am writing this code. output_toggle(PIN_C13); I am writing. I can't see a 2us pulse.
 
  setup_timer2(TMR_INTERNAL | TMR_DIV_BY_1, 49); ///2 us overflow, 2 us interrupt
 
 
But #use delay(crystal=25MHz)
 
setup_timer2(TMR_INTERNAL | TMR_DIV_BY_256, 244); When I write this code, 10ms pulse appears. What is the problem
 
I toggle every time it enters the interrupt. shouldn't it work? _________________ Best Regards...
 
MCUprogrammer
 
_______________________________
 
Work Hard | 
			 
		  | 
	
	
		  | 
	
	
		
			MCUprogrammer
 
 
  Joined: 08 Sep 2020 Posts: 233
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Mon Jan 09, 2023 9:27 am     | 
				     | 
			 
			
				
  | 
			 
			
				No, I think BROWNOUT is disabled. Because I didn't write #fuse BROWNOUT on the line. _________________ Best Regards...
 
MCUprogrammer
 
_______________________________
 
Work Hard | 
			 
		  | 
	
	
		  | 
	
	
		
			newguy
 
 
  Joined: 24 Jun 2004 Posts: 1924
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Mon Jan 09, 2023 9:49 am     | 
				     | 
			 
			
				
  | 
			 
			
				| The .lst file will show you, right at the bottom, the configuration fuses for your project. Don't assume that, since you didn't explicitly set a fuse, that it isn't actually set by default. | 
			 
		  | 
	
	
		  | 
	
	
		
			MCUprogrammer
 
 
  Joined: 08 Sep 2020 Posts: 233
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Mon Jan 09, 2023 9:55 am     | 
				     | 
			 
			
				
  | 
			 
			
				 	  | Code: | 	 		  
 
Configuration Fuses:
 
   Word  1L: FFFF   NOWRTB NOBSS NOBS NOWRT NOPROTECT NOWPCFG NOPROTECT_CFG NOAIVT
 
          H: 0000  
 
   Word  2L: FFFF  
 
          H: 0000  
 
   Word  3L: FFFF  
 
          H: 0000  
 
   Word  4L: FFFF  
 
          H: 0000  
 
   Word  5L: FFFF  
 
          H: 0000  
 
   Word  6L: 7FFF  
 
          H: 0000  
 
   Word  7L: FFF9   FRC_PLL IESO
 
          H: 0000  
 
   Word  8L: FF3B   NOPR OSCIO IOL1WAY CKSFSM PLLWAIT
 
          H: 0000  
 
   Word  9L: FF9F   WPOSTS16 WPRES128 NOWDT WINDIS WDTWIN_25%
 
          H: 0000  
 
   Word 10L: FFFF   BROWNOUT
 
          H: 0000  
 
   Word 11L: FFFF   ICSP1 NODEBUG
 
          H: 0000  
 
   Word 12L: FFFF  
 
          H: 0000  
 
   Word 13L: FFFF  
 
          H: 0000  
 
   Word 14L: FFFF  
 
          H: 0000  
 
   Word 15L: FFFF  
 
          H: 0000  
 
   Word 16L: FFFE   DMT_SW
 
          H: 0000  
 
   Word 17L: FFFF   PWMLOCK NOALTI2C1
 
          H: 0000  
 
   Word 18L: FFFF   ALTWREG1=NO ALTWREG2=NO
 
          H: 0000   | 	 
  _________________ Best Regards...
 
MCUprogrammer
 
_______________________________
 
Work Hard | 
			 
		  | 
	
	
		  | 
	
	
		 |