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

Does changing a timer prescale reset its count ?

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



Joined: 02 Dec 2003
Posts: 262

View user's profile Send private message

Does changing a timer prescale reset its count ?
PostPosted: Mon Sep 20, 2004 1:09 am     Reply with quote

I'm working on a pulse wave maker that will eigther output 100us or 200us pulses depending on the bits in my X varaible...

I cant use delay_us since I have other priority things going on.

I was thinking of setting up a timer so that it made an int every 100us, but if I saw that my next bit will be a long pulse then it changes the postscale or prescale so that it will int at 200us then next time around, when I then check the next bit and adjust the scale if it needs it,

Maybe there is an eaisy way to do this ? I need somthing that is FAST since I have a little math to do before I know what the scale needs to be and 100us on a 1MHz chip is pushing it, ESP with the interupt overhead.

Ideas ?
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Mon Sep 20, 2004 2:15 am     Reply with quote

Use the PWM module is your PIC has it. It is a hardware module and will not have any software overhead.
Mark



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

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

PostPosted: Mon Sep 20, 2004 7:44 am     Reply with quote

Another option is to try using the CCP module.
iso9001



Joined: 02 Dec 2003
Posts: 262

View user's profile Send private message

PostPosted: Mon Sep 20, 2004 5:12 pm     Reply with quote

How could I use PWM to output my square wave if one pulse is short then there might be two longs and then maybe 3 shorts ?

The same goes for CCP... isn't that for capture, compare and pwm ?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Sep 20, 2004 5:24 pm     Reply with quote

See the CCS example file, EX_CCP1S.C which shows how to generate
a pulse by using the CCP.
Look in this folder: c:\Program Files\Picc\Examples









-------
Edited for a typo.


Last edited by PCM programmer on Mon Sep 20, 2004 9:41 pm; edited 1 time in total
iso9001



Joined: 02 Dec 2003
Posts: 262

View user's profile Send private message

PostPosted: Mon Sep 20, 2004 6:33 pm     Reply with quote

Oh, I see.... Cool

So thats what Compare is for.... well, hmm... How can I use this to output a long string of bits witout using an interupt ?
J_Purbrick



Joined: 16 Sep 2003
Posts: 9

View user's profile Send private message

PostPosted: Mon Sep 20, 2004 9:12 pm     Reply with quote

I don't think you can send a "long string of bits" without an interrupt. And if you use CCS's interrupt service routine, the time to process each one ("pushing" and "popping" registers) will gobble all your cycles and more, if your oscillator really is 1MHz. With 20MHz you shouldn't have much trouble.

People have worked marvels with assembly language carefully arranged to take exact times between events, but you'd need to be desperate.

You could set up a serial port to produce a few sequential bits with your choice of 1's and 0's in a pattern, but you'd be stuck with the start and stop bits.
iso9001



Joined: 02 Dec 2003
Posts: 262

View user's profile Send private message

PostPosted: Tue Sep 21, 2004 1:09 pm     Reply with quote

I figured I could do it by keeping track of what bit I'm on and as the code loops around inside the main while() I could progress like that... but even THAT seems desperate,

I'm just going to figure out the 5 3 byte commands I need, and do what I'm doing now, which is

output_high; delay_X;
output_low; delay_X;
output_high; delay_X;
output_low; delay_X;

Its not really the best way sinceI basically shutting the rest of the functions of untill I'm done, but it does save on cpu time. Besides the rest of my functions have +- 5 ms of tollerance, I think I should be ok
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