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

18F67J11 - OSCILLATOR

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



Joined: 30 Jun 2017
Posts: 12

View user's profile Send private message

18F67J11 - OSCILLATOR
PostPosted: Tue Aug 22, 2017 1:35 am     Reply with quote

Hi All

Apologies for asking a very silly question. I can see that 18F67J11 can run on 48Mhz clock. My question is does it mean that I can use an external crystal of 48Mhz? or should I use 16Mhz external crystal and enable PLL.

I tried using 48mhz external crystal with following code, but LED does not blink at 2sec interval.

Please clarify.

Code:


#include<18f67j11.h>
#include <stdio.h>
#fuses HS,PROTECT,NOIESO,NOWDT
#use delay(clock=48000000)

#byte PORTF   = 0xF85


#bit RLY1=PORTF.1

void main()
{
set_tris_f(0x00);


   while(1){
      RLY1=1;
      delay_ms(2000);
      RLY1=0;
      delay_ms(2000);
   
   }

}




2. If I use 16Mhz Crystal, should I used H4_SW fuse instead of HS and configure clock as 48Mhz for PLL?

Thank you
Ttelmah



Joined: 11 Mar 2010
Posts: 19186

View user's profile Send private message

PostPosted: Tue Aug 22, 2017 2:45 am     Reply with quote

Read the data sheet. Maximum _crystal_ supported is 25MHz. Section 1A of the electrical specifications.

No.

The maximum crystal frequency supported in HSPLL mode is 10MHz, to give 40MHz operation. To run at 48Mhz, you have to use an external oscillator module.
gdrarun



Joined: 30 Jun 2017
Posts: 12

View user's profile Send private message

PostPosted: Thu Nov 23, 2017 11:54 pm     Reply with quote

Hi

I am back with the same old question. So far I have been testing the PIC with 4Mhz external crystal connected to it.

Started to experiment with UART @ 115200 and I switched to 25Mhz external crystal. The issue that I am facing right now is that the controller keeps on restarting on and on.

I tried to hooked it up with 10Mhz and the fuse to H4_SW, for 40Mhz operation. But the controller isn't working. Please advise.

Kindly note that I am working only with external crystal and not the internal one. I know that I am making something wrong with the fuses. But can't figure out.

Code:

#include<18f67j11.h>
#include <stdio.h>
#fuses HS,PROTECT,NOIESO,NOWDT
#use delay(clock=25000000)

#byte PORTF   = 0xF85
#bit RLY1=PORTF.1

void main()
{
set_tris_f(0x00);
RLY1=0;
delay_ms(3000);


   while(1){
      RLY1=1;
      delay_ms(1000);
      RLY1=0;
      delay_ms(1000);
   }

}
Ttelmah



Joined: 11 Mar 2010
Posts: 19186

View user's profile Send private message

PostPosted: Fri Nov 24, 2017 12:15 am     Reply with quote

Look at your hardware.

The faster you go, the more careful you have to be about decoupling around the chip.
How is your supply generated?.
How is it smoothed?.
Seeing you operating a line called 'RLY1', suggests a relay. How is this connected?. What trapping have you got for the energy in it's coil when you switch off?. If it is an LED, then what resistor are you using to feed it?.

Your fuses are OK, except don't use 'protect'. Using this while developing code, will reduce the life of the chip. Every time you try even a tiny change, the whole chip and the configuration fuses have all to be erased when this is used. Otherwise only things that change have to be erased.

There are obvious questions about how the crystal is wired. Have you got a part number or manufacturers link for the 25Mhz crystal being used?. What loading capacitors are you using?. How close is it to the chip?. Picture of the layout would be useful.
gdrarun



Joined: 30 Jun 2017
Posts: 12

View user's profile Send private message

PostPosted: Fri Nov 24, 2017 4:21 am     Reply with quote

Thank you so much for your information. I think I have found the problem.
Modified the code and connected 10Mhz Crystal to run the PIC @ 40Mhz. Kindly clarify what I am doing is right.
Code below.

Code:

#include<18f67j11.h>
#include <stdio.h>
#fuses H4_SW,PROTECT,NOIESO,NOWDT,NOSTVREN,NODEBUG,NOFCMEN
#use delay(clock=10000000)
#use rs232(baud=115200, xmit=PIN_C6, rcv=PIN_C7, stream=TFT, errors)


#byte PORTF   = 0xF85
#bit RLY1=PORTF.1

void main()
{
set_tris_f(0x00);
RLY1=0;
delay_ms(3000);


   while(1){
      RLY1=1;
      delay_ms(500);
      RLY1=0;
      delay_ms(1000);
   }

}


The above code works fine. Until I modify the while loop with some delay as below

Code:

while(1){
      RLY1=1;
      delay_ms(500);
      RLY1=0;
      delay_ms(1000);
   }


In short the PIC restarts when I add a delay that is higher than 500ms.

Please advise.

I have not connected anything to the I/O PIN RLY1. As you guessed it is for relay, but left floating right now to check the restart issue.
Ttelmah



Joined: 11 Mar 2010
Posts: 19186

View user's profile Send private message

PostPosted: Fri Nov 24, 2017 5:04 am     Reply with quote

Er.
As posted, the delay you say does work, is the same as the delay you say doesn't......

Your clock setting though is wrong. Your clock is 40MHz, if you are running H4, with a 10Mhz crystal.
This though would just mean the timings are wrong.

Are you sure your supply smoothing is good?.
What have you got connected to the MCLR pin?.
Are you sure your capacitor on the VddCore pin is OK?.
gdrarun



Joined: 30 Jun 2017
Posts: 12

View user's profile Send private message

PostPosted: Fri Nov 24, 2017 8:37 pm     Reply with quote

Hi

Sorry made a mistake when I posted the code. Fuse set to HS with clock 10M and not H4 with 10M. Sorry about it.

It's been a day trying to solve the problem. As I said earlier it looks like the problem is not with the delay statement alone. If I do add more functions or statements the PIC resets and commenting a few lines keeps the PIC running normal.

MCLR is connected to 3.3 with 4K7
VDDCORE is having 10mfd 25V TANTULUM
ENVREG to Ground.

Thanks a lot.
gdrarun



Joined: 30 Jun 2017
Posts: 12

View user's profile Send private message

PostPosted: Fri Nov 24, 2017 9:45 pm     Reply with quote

FYI, Running the PIC with Internal Clock @ 8 Mhz Works Good.

Code:

#include<18f67j11.h>
#include <stdio.h>
#fuses INTRC,PROTECT,NOIESO,NOWDT,NOSTVREN,NODEBUG,NOFCMEN
#use delay(clock=8000000)
#use rs232(baud=115200, xmit=PIN_C6, rcv=PIN_C7, stream=TFT, errors)


#byte PORTF   = 0xF85
#bit RLY1=PORTF.1

void main()
{
set_tris_f(0x00);
RLY1=0;
delay_ms(3000);


   while(1){
      RLY1=1;
      delay_ms(500);
      RLY1=0;
      delay_ms(1000);
   }

}


The same code when compiled for 32Mhz doesn't work at all.

Code:

#fuses INTRC_PLL_IO,PROTECT,NOIESO,NOWDT,NOSTVREN,NODEBUG,NOFCMEN
#use delay(clock=32000000)

setup_oscillator(OSC_32MHZ|OSC_PLL_ON);

PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Nov 24, 2017 10:51 pm     Reply with quote

1. Did you buy the board with the 18F67J11 on it ? If so, post the
manufacturer and model number of the board. Post a link to the
website for the board.

If you built it yourself, then post a close-up photo that shows the whole
board.

2. Post your CCS compiler version.

3. Also, get rid of the PROTECT fuse. There is no reason to have it
during testing.
gdrarun



Joined: 30 Jun 2017
Posts: 12

View user's profile Send private message

PostPosted: Fri Nov 24, 2017 11:24 pm     Reply with quote

The board wasn't a ready made one. How can I post the image here. Please advise.

CCS Version : 4.057

Kindly note that this works.

Code:

#fuses H4_SW,NOWDT,NOPROTECT,NOIESO,NOWDT
#use delay(clock=10000000)


And having the clock specified at 40000000 - doesn't work. The PIC doesn't even start.

Code:

#fuses H4_SW,NOWDT,NOPROTECT,NOIESO,NOWDT
#use delay(clock=40000000)


Just confused with everything.

Table 28-6 in datasheet explains Min OSC Frequeency is 4 and Max 10 in HSPLL oscillator mode and MIN 4 and MAX 25 in HS MODE. Am I making anything wrong in setting to 40Mhz.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Nov 25, 2017 10:31 pm     Reply with quote

Quote:
How can I post the image here ?

Use a free image hosting website. Find one by Googling for that.
Upload your image to the website. Then post a link to it here.

Google for this:
Quote:
free image hosting site without registration
Ttelmah



Joined: 11 Mar 2010
Posts: 19186

View user's profile Send private message

PostPosted: Sun Nov 26, 2017 4:35 am     Reply with quote

gdrarun wrote:
The board wasn't a ready made one. How can I post the image here. Please advise.

CCS Version : 4.057

Kindly note that this works.

Code:

#fuses H4_SW,NOWDT,NOPROTECT,NOIESO,NOWDT
#use delay(clock=10000000)


And having the clock specified at 40000000 - doesn't work. The PIC doesn't even start.

Code:

#fuses H4_SW,NOWDT,NOPROTECT,NOIESO,NOWDT
#use delay(clock=40000000)


Just confused with everything.

Table 28-6 in datasheet explains Min OSC Frequeency is 4 and Max 10 in HSPLL oscillator mode and MIN 4 and MAX 25 in HS MODE. Am I making anything wrong in setting to 40Mhz.


No. The oscillator frequency is not the CPU clock.
This is the point of the PLL. It allows you to use a crystal at (say) 10MHz, which is then inside what the chip's oscillator supports, while running the chip at 40MHz clock.
temtronic



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

View user's profile Send private message

PostPosted: Sun Nov 26, 2017 6:26 am     Reply with quote

Just to add to Mr. T's comments...

...with newer PICs it's important to look at the diagram of the 'clock signal path' that Microchip puts in the datasheet. Newer PICs have a complex path to get the 'clock' from source to destination. The 'source' can be one of 2 or 3 internal osillators and 3 or 4 external circuits. Add to that pre scalers, post scalers , PLL ,PLL divider sections and it can be quite confusing ! I made my life simpler by printing off that diagram then using a highlighter pen to show the 'flow' of my desired clock. Not all PICS are the same so it's best to look/read the clock section of the datasheet very carefully when using a different PIC from what you know .

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19186

View user's profile Send private message

PostPosted: Sun Nov 26, 2017 8:39 am     Reply with quote

gdrarun wrote:
Hi

Sorry made a mistake when I posted the code. Fuse set to HS with clock 10M and not H4 with 10M. Sorry about it.

It's been a day trying to solve the problem. As I said earlier it looks like the problem is not with the delay statement alone. If I do add more functions or statements the PIC resets and commenting a few lines keeps the PIC running normal.

MCLR is connected to 3.3 with 4K7
VDDCORE is having 10mfd 25V TANTULUM
ENVREG to Ground.

Thanks a lot.


Whoa....

What voltage are you running?.

If you have ENVREG to ground, you have the internal voltage regulator disabled, so must be feeding 2.75v _max_ into the Vddcore pin yourself.
Are you supplying this?.
If not, it is amazing the chip runs at all!...

The core is being powered by leakage currents from the I/O drivers. Hardly surprising it goes wrong.
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