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

Can I run at 40Mhz

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



Joined: 19 Nov 2003
Posts: 45
Location: Oxford

View user's profile Send private message Visit poster's website

Can I run at 40Mhz
PostPosted: Tue Aug 03, 2004 9:56 am     Reply with quote

I am using a PIC18F8621 with a 40MHz external clock (DS1075-080).

I want to check the inputs of two digital ports and comparing them to the previous values if any are different I record them to the internal memory and record the time.

I would like to do this as quickly as possible (technically 1us would be great but I can just about live with 5). I will be needing to use an interrupt to make sure that I have a constant loop time.

I have made a small progam to see how fast I can go and I appear to go fairly slow 10us for the below program. This makes me think that I am either not setup the PLL correctly or that the interrupt is not correctly done

What settings should I be using

I have configured (in MPLAB IDE configure>configuration bits) to EC-OSC2 as RA6, software enabled 4xPLL (should i use hardware or software???).

Code:
#define Fosc 40000000                 // I'm using a 40 MHz crystal
#include <18F8621.h>
//-------------------------------------------------------------------------------------
// COMPILER DIRECTIVES and HARDWARE CONFIGURATION
#use delay(clock = Fosc)
//-------------------------------------------------------------------------------------
// GLOBALS - GENERAL
static short state = 0;    //State Switch for watchdog
//-------------------------------------------------------------------------------------
// INTERRUPTS
#int_rtcc
void int_rtcc_isr(void)
{
   set_timer0(65475);      
   state=~state;
}
//-------------------------------------------------------------------------------------
// MAIN
void main()
{
   setup_counters(RTCC_INTERNAL, RTCC_DIV_1);
   set_timer0(65475);                   
      enable_interrupts(GLOBAL);         // set global interrupts
      enable_interrupts(INT_RTCC);        // disable timer interupt

   while (1)
    {
      output_bit(PIN_H0,state);   
      }
}


When I try to add fuses the EC-OSC2 as RA6, software enabled 4xPLL in the configuration settings changes to RC-OSC2 as RA6.

I am not sure if i should be using timer1 as my interrupt as I think it is being used in the actual clock timing.

What configuration settings do i need, what fuses and registers do I need to set, what timer/interrupt and its configuration do I need to make this go the fastest it can

Any help from you lot would be excellent as I am beginning to go slightly mad
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Tue Aug 03, 2004 10:47 am     Reply with quote

At 40Mhz, 1us is only 10 instructions and 5us would be 50 instructions. You won't stand a chance of doing this with the standard int handler. I suggest you use the high priority int and write your own handler. RJ Hamlett has posted many times on int handlers. Search for his posts under Ttelmah for examples.
Guest








PostPosted: Tue Aug 03, 2004 11:00 am     Reply with quote

The maximum clock for this device is 40Mhz. If you are using an external 40Mhz source, you don't need to use the PLL.
Guest








PostPosted: Tue Aug 03, 2004 11:12 am     Reply with quote

Mark wrote:
Search for his posts under Ttelmah for examples.

I get nothing when I do an author search of Ttelmah??
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Aug 03, 2004 11:42 am     Reply with quote

The board doesn't support author search for unregistered user names
...unfortunately.

Since he always signs his posts with "Best Wishes", you can build your
search string like this:

best wishes interrupts

Then set it to Search For All Terms.
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