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

measure frequency prescaler

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



Joined: 23 Feb 2008
Posts: 29

View user's profile Send private message

measure frequency prescaler
PostPosted: Wed Mar 25, 2009 3:29 pm     Reply with quote

Hi!

I need a pin-out (example b5) on a 16F877 the exact frequency of timer1 prescaler? I would like to measure with frequency meter the frequency of the prescaler.

I recommended that code?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 25, 2009 3:47 pm     Reply with quote

There is no way to bring the Timer1 Prescaler clock to an i/o pin.

There is no option in the 16F877 hardware to do this.
volcane



Joined: 23 Feb 2008
Posts: 29

View user's profile Send private message

PostPosted: Wed Mar 25, 2009 3:55 pm     Reply with quote

PCM programmer wrote:
There is no way to bring the Timer1 Prescaler clock to an i/o pin.

There is no option in the 16F877 hardware to do this.


you can do with software? I would like to know the error of the oscillator
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 25, 2009 4:16 pm     Reply with quote

You have full control over the application program in the PIC.
You can create a loop that toggles a pin. Example:
Code:
#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)

//======================================
void main()
{
output_low(PIN_B5);

#use fast_io(b)
while(1)
 {
  output_high(PIN_B5);
  output_low(PIN_B5);
 } 

}


Then look at the .LST file to see what ASM code is generated by the
compiler:
Code:
.................... while(1)
....................  {
....................   output_high(PIN_B5);
0010:  BSF    PORTB.5
....................   output_low(PIN_B5);
0011:  BCF    PORTB.5
....................  }   
0012:  GOTO   010

That's a total of 4 instruction clocks. The BSF and BCF each take 1 clock.
The GOTO takes 2 clocks. So the signal on pin B5 will be the instruction
clock divided by 4. The instruction clock is 1/4 of the crystal frequency,
so it's 1 MHz. Then the loop above divides it by 4, to give 250 KHz on
pin B5. You can measure that with an oscillocope or frequency meter.
volcane



Joined: 23 Feb 2008
Posts: 29

View user's profile Send private message

PostPosted: Thu Mar 26, 2009 2:35 pm     Reply with quote

Thanks works perfectly
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