SHDesigns: Embedded Systems Design, Consulting and Developer Resources Page hits:

Rabbit Programming Tips

Use a serial port to generate a continuous clock

This is actually quite simple:


 Dynamic C:

The above sets timer A5 up for divide by 8 and set serial port B for synchronous mode. If the serial port is never given a start command and nothing is written to the data reg, the port will send a continuous clock.

The serial port can not be used, but the TX and RX pins can be used for bit I/O.

This requires no code to maintain the clock so it is 0 overhead. The clock is stable and has no jitter. Note: a very small amount of jitter will occur if the clock spreader is on.

The output frequency is CPU CLK/(n+1)/4, where 'n' is the value written to the TATxR register. So, the maximum clock speed is CLK/4 and the minimum is CLK/1024. You can set up the timer to be clocked from timer A1, but that might interfere with serial ports (timer A1 is usually set to /16).

Clock Generator Pins and Regs
 Port  CLK Pin  Timer Reg  Control Reg

Be sure to set the the pin function and direction regs for the clock pins. Also, make sure the timer is set up to be clocked by PCLK (unless you want to cascade it with timer A1.)

Additional Information: Back to Tips page - SHDesigns Home Page