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

How to set timer up for simultaneous 4ch PWM, RS232, I2C?

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



Joined: 11 Jun 2006
Posts: 4

View user's profile Send private message

How to set timer up for simultaneous 4ch PWM, RS232, I2C?
PostPosted: Sun Jun 25, 2006 6:48 pm     Reply with quote

I am developing a project that has a few different signals that all need to run simultaneously. I've done a few projects that only done one or two things but this one seems a little harder to me... My signals are:

- 4-channel PWM (red, green, blue LED's and 1x DC speed control) at about 4.4 mS
- RS232 8,n,1 @ 2400bps (rx + tx)
- I2C EEPROM (24AA08)
- Infrared remote using Philips RC-5 protocol
- Also some other signals that doesn't relate to the question..

I am hoping to do all this on a PIC16F684 @ 8 MHz.

The only way I can think to do it is to use a 8uS timer and four variables (1 for each signal type) to offset the timer. I don't see how I could generate an interrupt for each, and if I did an interrupt every 8uS I couldn't get that much done between them.

Does anyone have any suggestions, or possibly some example code?

Thanks,

Neil
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jun 26, 2006 3:29 pm     Reply with quote

I would use the multi-tasking approach, as described in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=17189

Low speed processes are checked or updated at the tick rate (10 ms).
These would be keypad, checking RS-232 receive buffer, etc.
(This assumes an interrupt-driven RS-232 receive fifo).

High speed processes run independently at their own rate. These
could be running on a timer interrupt that runs faster than the tick rate.
(A separate hardware timer, other than the tick timer). This could
be the RC-5 receiver and the software PWM.

I'm not sure if you can do all of this in a PIC, unassisted by external
hardware. Normally, I try to use as many of the PIC's hardware
modules as possible.
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