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

PIC18F4620 INT_RB maximum speed

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



Joined: 30 Oct 2007
Posts: 553
Location: Ottawa, Ontario, Canada

View user's profile Send private message

PIC18F4620 INT_RB maximum speed
PostPosted: Wed Aug 15, 2012 6:54 am     Reply with quote

Hello, I guess I will try this by trial and error when I get a chance but hopefully in the mean time someone might be able to answer.... I realize that many things can impact the speed of interrupts BUT considering the following:

In my main, I have a simple infinite while loop:
Code:
while(1);

I also have the #INT_RB interrupt routine simply do the following:
Code:

#int_RB                                 
void RB_isr(void)
{                       
   // Read PORT B
   uiPortB = input_b();

   (sPinB4 below is a one bit SHORT)

   // Read the entire port B, isolate PIN_B4 with the bit mask,
   // shift all bits over by 4 to have sPinB4 be the actual PIN_B4's
   // state
   sPinB4 = ( uiPortB & 0x10 ) >> 4;

   // Ouput sPinB4's value on PIN_D4
   output_bit( PIN_D4, sPinB4 );
}


Currently, on PIN B4, I give it a 50% duty cycle square wave of 8kHz. This results in having the same 8kHz onto PIN D4, but with a delay.

So my question is: what's the maximum frequency I could put with this simple program onto PIN B4?

I will do some more tests since I have a partial program running. I am currently testing with 8kHz and it's working. The delay between B4's low-to-high transition and D4's L-t-H transition is exactly 15 us.

Has anyone tested this with higher frequencies? I will share my findings here once I manage to figure it out but in the mean time, if someone has answers, please let me know.

I'm using a PIC18F4620 and my crystal is 16.384Mhz (for specific reasons not explained here but I need that crystal).

CCS Compiler version 4.056.

Thanks!
drolleman



Joined: 03 Feb 2011
Posts: 116

View user's profile Send private message

PostPosted: Wed Aug 15, 2012 9:54 am     Reply with quote

Test it. hook a scope to an unused pin turn in on at the start of the isr amd then off and the end of the isr and you get your answer.
benoitstjean



Joined: 30 Oct 2007
Posts: 553
Location: Ottawa, Ontario, Canada

View user's profile Send private message

PostPosted: Wed Aug 15, 2012 10:05 am     Reply with quote

Thanks but if you read closely, that's what I'm doing currently with 8kHz. I read the port and make PIN D4 the same state as my interrupt-on-change PIN B4.

On my scope, I have probe A to PIN B4 and probe B to pin D4. If I measure the delay between the rise time of both signals (it's an 8kHz 50% duty), there's 15us.

What I want to know is how fast is the fastest I will be able to do this.... I am trying with 64kHz and I don't think my PIC can handle interrupts that fast as PIN D4 is totally NOT the same as PIN B4 in this case (looking at my scope).

The problem is I don't have a frequency generator so it's a bit long to test with the PWM at different frequencies.

Again, I will most likely get my answer soon by trying out different PWM frequencies but as mentioned, I was just curious to see if someone already had the answer before I did all the work.

So, so far, 64kHz seems too fast.
benoitstjean



Joined: 30 Oct 2007
Posts: 553
Location: Ottawa, Ontario, Canada

View user's profile Send private message

PostPosted: Wed Aug 15, 2012 10:28 am     Reply with quote

So I think I've figured-it out. Using a 16.384MHz crystal, if I set my PWM to these settings:
Code:

setup_timer_2( T2_DIV_BY_4, 49, 1 );
set_pwm1_duty( 25 );

It gives me a 20.48 kHz 50% duty wave on my PWM which I feed in interrupt PIN B4. The result is output PIN D4 (since I read pin B4 and apply its state to output PIN D4).

I say 20.48kHz because that's a perfect round number using the given crystal frequency. It's probably a bit more but afterwards, the delay between the rise-times of the interrupt versus the output pin will start overlapping.

Can someone confirm that this would make sense?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Aug 15, 2012 1:33 pm     Reply with quote

Explanations of maximum isr speed:
http://www.ccsinfo.com/forum/viewtopic.php?t=43399
http://www.ccsinfo.com/forum/viewtopic.php?t=40169
How to test an interrupt flag to control program flow, without an isr:
http://www.ccsinfo.com/forum/viewtopic.php?t=41403
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