AVR135: Using Timer Capture to Measure PWM Duty Cycle Documentation
Atmel AVR Application Note
This documents functions, variables, defines, enums and typedefs in the software for application note AVR135: Using Timer Capture to Measure PWM Duty Cycle
icp.c contains functions for use of the demodulator.
main.c contains a simple program to demonstrate the demodulator operation. It generates a PWM signal on OC2, then samples the demodulator output using calls to icp_rx() and writes the values obtained to PORTC.
Approximately twice per second, OCR2 is incremented such that the PWM duty cycle steps through the entire [0:256) range.
The intended use is on the STK500/STK501, with a 10-wire jumper connecting the PORTC header with the LEDs header and a single-wire jumper connecting PB7 (OC2) with PD4 (ICP1).
The expected result is that the LED display cycles repeatedly from 0x00 to 0xFF.
This software was written for the IAR Embedded Workbench, 3.20C, but can also be built using newer versions of IAR, and also GCC (see note below).
To make project for IAR EWAVR: Add the .c files to project (main.c and icp.c). Use device --cpu=m64, small memory model, optimization low for debug target and high for release, output format: ubrof8 for Debug and intel_extended for Release.
A makefile is included for use with GCC. Defines are included in code to make porting to GCC easy.
This example is written for ATMega64, but all devices with an Input Capture Unit can be used.
The demonstration is tuned for a 3.6864MHz clock, but clock speed is not critical to correct operation.
Generated on Wed Nov 2 14:20:47 2005 for AVR135: Using Timer Capture to Measure PWM Duty Cycle by
1.4.4