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 CCS Technical Support

Internal clock 32MHz in PIC18F2685

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







Internal clock 32MHz in PIC18F2685
PostPosted: Sun May 03, 2009 10:17 pm     Reply with quote

I could not get config the PIC.

I used the next code:
Code:
   setup_oscillator(OSC_8MHZ|OSC_PLL_ON);
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun May 03, 2009 10:42 pm     Reply with quote

See this post:
http://www.ccsinfo.com/forum/viewtopic.php?t=38761&start=1
germansket
Guest







PostPosted: Mon May 04, 2009 11:29 am     Reply with quote

I used the next code and doesnt work at 32 MHZ
Code:

#include <18F2685.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES INTRC_IO                 //Internal RC Osc, no CLKOUT
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOBROWNOUT               //No brownout reset
#FUSES BORV20                   //Brownout reset at 2.0V
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOCPD                    //No EE protection
#FUSES NOSTVREN                 //Stack full/underflow will not cause reset
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or
#FUSES NOWRT                    //Program memory not write protected
#FUSES NOWRTD                   //Data EEPROM not write protected
#FUSES NOIESO                   //Internal External Switch Over m
#FUSES NOFCMEN                  //Fail-safe clock monitor disabled
#FUSES NOPBADEN                 //PORTB pins are configured as digital
#FUSES BBSIZ4K                  //4K words Boot Block size
#FUSES NOWRTC                   //configuration not registers write protect
#FUSES NOWRTB                   //Boot block not write protected
#FUSES NOEBTR                   //Memory not protected from table reads
#FUSES NOEBTRB                  //Boot block not protected from table rea
#FUSES NOCPB                    //No Boot Block code protection
#FUSES LPT1OSC                  //Timer1 configured for low-power operati
#FUSES NOMCLR                   //Master Clear pin used for I/O
#FUSES NOXINST                  //Extended set extension and Indexed Ad

#byte OSCTUNE = 0XF9B
#byte OSCCON = 0XFD3

#use delay(clock=32000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)


void main()
{
  int variable;
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF|ADC_TAD_MUL_0);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
   setup_vref(FALSE);

   setup_oscillator(OSC_32MHZ|OSC_PLL_ON);
   do
   {
    variable++;
    printf("V=%u",variable);
    output_bit( PIN_B0, 1);
    delay_ms(10);
    output_bit( PIN_B0, 0);
   }while(TRUE);
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon May 04, 2009 11:38 am     Reply with quote

Try the simple program in my link.

Also post your compiler version. It's given at the top of the .LST file.
The .LST file is in your project directory. The version number is in
this format: x.xxx
germansket
Guest







PostPosted: Mon May 04, 2009 11:44 am     Reply with quote

It is working very well. I didn't measure well with the scope. The code is ok.

Thanks PCM.

The problem is that when I simulated in MPLAB the register OSCTUNE bit 6 is 0 "zero" when should be 1 if I use the PLL. But when I program the pic, this work in 32 mhz.
I don't know what it is the problem in the simulate.
germansket
Guest







PostPosted: Mon May 04, 2009 12:50 pm     Reply with quote

PCM programmer wrote:
Try the simple program in my link.

Also post your compiler version. It's given at the top of the .LST file.
The .LST file is in your project directory. The version number is in
this format: x.xxx


The compiler version is 4.065 and I simulated with MPLAB 8.

Regards.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon May 04, 2009 1:05 pm     Reply with quote

Read the MPLAB Help file for the Simulator. It says:
Quote:

The internal oscillator can be changed in software, but will not affect of
the speed of the oscillator during runtime.
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