AVR136: Low-Jitter Multi-Channel Software PWM Documentation
Atmel AVR Application Note
This documents data structures, functions, variables, defines, enums, and typedefs in the software for application note AVR136.
This software was written for the both IAR Embedded Workbench 4.11A and GCC 3.4.3.
To make project when using IAR Embedded Workbench:
-
Add the file t2313_softpwm.c to project.
-
Under processor configuration, select ATtiny2313
-
Enable bit definitions in I/O include files
The included source code is written for ATtiny2313, using the STK500 platform with a 7.3728MHz external crystal.
- Program the CKSEL fuse for external clock source (Ext.Clock)
- Connect PD0 to RXD and PD1 to TXD of the RS232 SPARE header on the STK500.
- Connect the RS232 port to a PC running a terminal program set for 8N1 at 38,400 Baud. Send commands using the four-character format: #nHH where:
- # is a sync character
- n = 0-9 for required channel number
- HH = hex value corresponding to 0-255 for PWM high period
Channels are mapped to specific port pins in the t2313_softpwm.h file
The PWM base frequency is the crystal frequency divided by 65536, e.g. for a 7.3728MHz crystal the PWM base frequency will be 112.5Hz. The standard STK500 3.6864MHz oscillator could be used as a clock source, but the PWM base frequency would be reduced which may result in unacceptable ripple. Jitter will be +/-1 clock cycle max, or +/-0.0015% of base frequency.
This demonstration shows ten PWM channels, for GCC the ISR uses less than 50% of processing time during the softcount=0 interrupt. The principles shown should accomodate up to 24 channels on suitable AVR devices whilst maintaining PWM accuracy, ISR optimisation may improve this even further.
- Todo:
- Select if ISR Timing Debugging is desired in DEBUG.
Andy Gayne is the original author of this application note.
Generated on Tue Dec 20 15:11:31 2005 for AVR136: Low-Jitter Multi-Channel Software PWM by
1.4.4