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

PIC18F2410 and 32MHz PLL

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



Joined: 28 Aug 2007
Posts: 106

View user's profile Send private message

PIC18F2410 and 32MHz PLL
PostPosted: Tue Mar 04, 2008 8:26 am     Reply with quote

Hi all,
I have problems getting the oscillator running at 32MHz. My output shows me- measured with the oscilloskope - only a toggle with 2MHz. So the controller seems to run only in 8MHz mode. All registers seems to be o.k.

OSCTUNE is 0x40 and OSCCON is 0x7C

Compiler Version is 4.038

Here is the code:
Code:
#include <18F2410.h>

#Fuses INTRC_IO,NOFCMEN,NOIESO,NOWDT,PUT,NOPROTECT,NOBROWNOUT,DEBUG,NOLVP,NOPBADEN

#USE delay (clock=32000000)

#USE STANDARD_IO (A)
#USE STANDARD_IO (B)
#USE STANDARD_IO (C)
#USE STANDARD_IO (E)


#define      AUSGABE      PIN_C2
#define      LED         PIN_C6
#define      INT         PIN_B2
#define      RESET      PIN_C7
#define      CS         PIN_A5
#define      CLK         PIN_C3
#define      DATA_IN      PIN_C4
#define      DATA_OUT   PIN_C5


#define NOP   #asm NOP #endasm;

short   SPI_GELESEN;

int    STAGE;
int      i;
int      array[10];

long   PULSWEITE_[4];


#INT_SSP
void SPI_int()
   {
   array[i] = spi_read ();
   ++i;


   }
   



#INT_TIMER1
void isr_timer1()
   {

   }

#INT_TIMER0
void isr_timer0()
   {

   }


void main()
   {
   SETUP_OSCILLATOR( OSC_32MHZ );

//   SETUP_OSCILLATOR( OSC_PLL_ON );
   SETUP_SPI(SPI_MASTER | SPI_H_TO_L | SPI_CLK_DIV_16 );

   enable_interrupts(GLOBAL);
   enable_interrupts(INT_SSP);

   ENABLE_INTERRUPTS(INT_TIMER0);
   ENABLE_INTERRUPTS(INT_TIMER1);

   SET_TIMER0(0);
   SETUP_TIMER_0 ( RTCC_INTERNAL | RTCC_DIV_1);    // 1 Timer Increment = 64µs

   SETUP_TIMER_1 ( T1_INTERNAL | T1_DIV_BY_8); // 1 Timer Increment = 4µs

   SETUP_ADC_PORTS(NO_ANALOGS);




   for(;;)
      {
      output_high(PIN_A2);
      output_low(PIN_A2);
      output_high(PIN_A2);
      output_low(PIN_A2);
      output_high(PIN_A2);
      output_low(PIN_A2);
      output_high(PIN_A2);
      output_low(PIN_A2);
      output_high(PIN_A2);
      output_low(PIN_A2);
      output_high(PIN_A2);
      output_low(PIN_A2);
      output_high(PIN_A2);
      output_low(PIN_A2);
      output_high(PIN_A2);
      output_low(PIN_A2);


   
   
      }//for()

   }//Main()
Ttelmah
Guest







PostPosted: Tue Mar 04, 2008 8:41 am     Reply with quote

32MHz clock, implies 8MIPS (4 clock cycles per instruction on the PIC).
Code:

      output_high(PIN_A2);
      output_low(PIN_A2);

Using _standard_io_ mode, which you are, implies _4_ instructions (clear the TRIS bit, set the output bit, clear the TRIS bit, clear the output bit).
4 instructions at 8MIPS=500nSec. You are running at 32MHz.

Best Wishes
richi-d



Joined: 28 Aug 2007
Posts: 106

View user's profile Send private message

PostPosted: Tue Mar 04, 2008 10:48 am     Reply with quote

Hi,

thank you- you are right- SPI is running with the right speed!
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