Personal tools
You are here: Home Downloads M16C / M32C Timers and PWM

Timers and PWM

Info on working with the M16C's timers and PWM abilities.

File 64 Minus 2 Simulator
This program will work on all Timer A versions of the M16C family including M16C/Tiny, 62P, 30P, and other Timer A equipped MCUs. This simple program simulates a 64-2 timing wheel for some Ford/GM model automobiles. There are 2 missing teeth on a typical timing wheel which allows the automotive computer to determine which bank of spark plugs to fire. This program uses timer A in event counter mode to sample a square wave input into the timer A pin (TA0IN). This input signal causes the timer to countdown until the timer underflows. At this point the timer interrupt triggers and the I/O port (P10_0) is toggled. Once the toggle count reaches 62 pulses, the I/O port is stopped at a 'L' level and the timer continues to count until it reaches 64 pulses. At this point the pulse train is restarted and the cycle continues.
File Input capture timer example.
This design provides a good example of using the input capture features of the M16C timers.
File More timer examples.
This projects uses timers on the M32C to control the ADC, control sine wave data for DTMF tone generation, and as a Real Time Clock.
File PWM of 7 segment LEDs.
This project uses a PWM channel to control brightness on 7 segment LED displays.
File Timer controlled DMA
This project uses system timers to control DMA channels. This project makes heavy use of DMA.
File Timer examples
This reference design provides code to use Timer B in Input Capture mode. Other timers are also used for various functions.
File Timer generates system tick.
This project uses a timer resource to generate a system tick and control PWM generation.
File Timer used to create beeps and timed delays.
This project uses timers to create various simple beeps as well as delay time functions.
File Timer used to create system tick/interrupt.
This project uses a timer to create a system tick.
File Tone Generation.
This example project uses the PWM to generate various tones.
File TRIAC control of heating element.
This project uses a PWM channel to control a Triac and AC heating element. The code also includes a simple PID loop.
File Vee bias voltage generation for LCDs
This project uses a PWM channel to generate the Vee bias voltage for a graphic LCD display.
File Simple PWM using DMA & Timer
The sample code in "62P_DMA_Fwd_Src_Repeat_w_Timer" shows how to set up multiple channel simple PWMs using a DMA and a timer. The concept enables the generation of PWM signals on multiple ports without involving the MCU core touching the timer or DMA peripheral. Only the RAM value 'data_src' for the PWM values needs to be changed by the application. The rest of the actual PWM generation runs once set up.