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

Questions about fuse and 18F4680

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



Joined: 20 Sep 2003
Posts: 47
Location: Brussel - Belgium

View user's profile Send private message

Questions about fuse and 18F4680
PostPosted: Sun May 24, 2009 4:26 am     Reply with quote

Hello,

I use 18F4680 and PCWH 3.217.
This Pic works with internal Xtal at 8 Mhz. Here the fuse and the relevant code.

Code:
#fuses NOWDT, HS, EC_IO, NOPROTECT, NOBROWNOUT, NODEBUG, NOLVP, MCLR,NOCPD, NOWRT, NOWRTD,STVREN,NOCPB, LPT1OSC,NOPBADEN 
#use delay(clock=8000000)
in the main
setup_oscillator(OSC_8MHZ|OSC_INTRC);

With this configuration I blink leds and have RS232 communication. That woks fine.
Now I wish work at 32 Mhz with the PLL enabled. Therefore I change HS with H4. But it's not working. I found in this forum the following instruction

Code:
setup_oscillator(OSC_8MHZ|OSC_PLL_ON );

That give compilation error, the keyword OSC_PLL_ON is not in the 18F4680.h file.
I try to change it in the OSCTUNE registre but without succes. Here the code :
Code:
#bit  OSCTUNE =0xF9B.6
in the beginning of the main:
....
setup_oscillator(OSC_8MHZ|OSC_INTRC);
OSCTUNE = 1;


When I print the value of OSCTUNE I have 0x00 and OSCON give the good value for 8 Mhz.
The conditions to enable the PLL are the use of 8 Mhz and FOSC3:FOSC0 = 1001 or 1000. Where can I found and (or) change the second condition ?
Is it possible to modify the 18F4680.h file to add OSC_PLL_ON ? If yes with value ?

Second problem, all ports in output mode works without A7. Which register to force A7 to be digital I/O mode ?

Last question : this Pic work fine with 2 PWM. The data sheet said it is possible till 4 PWM. I want to use 3 at the same frequency but different duty cycles. Is it possible ? I don't find the possibilities.

Thanks a lot for your help.

Guy Detienne.
dyeatman



Joined: 06 Sep 2003
Posts: 1923
Location: Norman, OK

View user's profile Send private message

PostPosted: Sun May 24, 2009 8:00 am     Reply with quote

The header file in 4.083 has the line:

#define OSC_PLL_ON 0x4000

.
GDetienne



Joined: 20 Sep 2003
Posts: 47
Location: Brussel - Belgium

View user's profile Send private message

PostPosted: Sun May 24, 2009 8:37 am     Reply with quote

Thanks for your answer. This code don't work, the Pic stays at 8 Mhz.
In my header file, the other codes are :
Code:

#define OSC_TIMER1  1
#define OSC_INTRC   2
#define OSC_NORMAL  0


Then your data 0x400 is not valid. I try with 4 and same result and osctune = 0.


Thanks.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun May 24, 2009 12:49 pm     Reply with quote

Quote:
Then your data 0x400 is not valid

He said 0x4000.

Quote:

I use 18F4680 and PCWH 3.217.
Now I wish work at 32 Mhz with the PLL enabled

You have a very early version. It's possible that setup_oscillator()
doesn't work correctly in that version. You can set it up manually with
two lines of code at the start of main(). Example:
Code:

#include <18F4680.h>
#fuses INTRC_IO,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=32000000)

#byte OSCCON  = 0xFD3
#byte OSCTUNE = 0xF9B

//======================================
void main(void)
{
OSCCON  = 0x70;
OSCTUNE = 0x40;


while(1);
}
GDetienne



Joined: 20 Sep 2003
Posts: 47
Location: Brussel - Belgium

View user's profile Send private message

PostPosted: Mon May 25, 2009 9:23 am     Reply with quote

I had try with 0x4000 and not with 0x400. Sorry, typing errror.

Your little example work fine at 32Mhz. He don't work with my fuse. I check what is wrong on it.

Do you have an idea for my port A7 and the third PWM output ?

Many thanks for your answer. Great help.

Guy Detienne.
GDetienne



Joined: 20 Sep 2003
Posts: 47
Location: Brussel - Belgium

View user's profile Send private message

PostPosted: Mon May 25, 2009 9:42 am     Reply with quote

My answer is not correct. The port A7 work now as digital I/O.
Sorry.

Somebody have an idea for the output of 3 PWM ?

Many thanks.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon May 25, 2009 1:53 pm     Reply with quote

Quote:

Last question : this Pic work fine with 2 PWM. The data sheet said it is
possible till 4 PWM. I want to use 3 at the same frequency but different
duty cycles. Is it possible ? I don't find the possibilities.

There are only 2 hardware PWM modules in the 18F4680. The 4 outputs
of the ECCP PWM are intended for a motor driver. They can't have
independent duty cycles.

If you want more hardware PWM modules, you need to use a different
PIC.

Or, you could use a low-speed software PWM, by using a timer interrupt.
GDetienne



Joined: 20 Sep 2003
Posts: 47
Location: Brussel - Belgium

View user's profile Send private message

PostPosted: Tue May 26, 2009 5:07 am     Reply with quote

Many thanks for your help.

Detienne Guy.
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