You could use a loop that repeatedly drives 2 software state-machines. Each state machine would be balanced so that the shorter state handlers have NOPs inserted to make the timing equal the longest state handler. An example of the states you might use: 1). Decrement period count and check for zero .. goto state 2 if zero 2). Raise output, set pulse-width counter, goto state 3 3). Decrement pulse width count and check for zero .. goto state 4 if zero 4). Drop output, set period count, goto state 1 Control could be dispatched to the state handlers though a table: (thus ensuring balanced timing) MOVF STATE,W ADDWF PCL,F GOTO STATE1 GOTO STATE2 ... The table would have to be aligned so as not to cross a page boundry ... see my post a few days ago or a Microchip databook (or just email me off-list) for the technique to deal with tables that do cross page boundries. If you use multi-byte decrements or increments in your state handlers then make sure you balance the timing so that it takes the same amount of time whether or not a carry/borrow is generated. A simple: MOVLW -1 ADDWF LOW_BYTE,F BTFSS STATUS,C DECF HIGH_BYTE,F does have balanced timing and will work fine for decrementing a 2-byte count. Cheers, Ken > All, > > I have a project in which I need two timers (software, not > hardware) and have them run asynchronously. Each will output > a pulse as soon as the time has run out. Both the period > and pulse width of each timer will be adjustable. Each timer > will control two seperate I/O pins assigned to that timer. > For some reason, my mind has come up blank and I can't even > get started. The delays from each timer can range from 1 to > 20 seconds, and the pulse width from 4 to 40 milliseconds. > But each has to service the pulse as soon as possible (within > microseconds) so as to be as accurate as possible. Anybody > have any ideas? Yes, this has to do with the timing routines > I asked for yesterday. And BTW, I got so many responses to > my question yesterday for timing routines, I now have an extra > hour in every day. ie 25 vs 24. If anyone has any ideas, I'd > be very grateful to hear them. I have only a limited amount > of time, and I need to get started soon to have it done in time. > Thanks to all. I do appreciate the time and responses. > > Regards, > > Jim > >jim@jpes.com