Timer0_PWM.c File Reference

#include "config.h"
#include "Timer0_PWM.h"

Include dependency graph for Timer0_PWM.c:

Go to the source code of this file.

Functions

void Timer0_start (void)
 Timer0_start configures timer 0 for PWM on Output compare 0 B Configures timer as following:
  • Count clock is Fosc/1 (prescaler -> clk/1), 8Mhz
  • Fast PWM mode use
  • Uses output compare pin OCR0B
  • OC0B is set from 0 to OCR0B, then cleared up to timer0 TOP
  • Waveform generator configured : Timer 0 top is 0xFF (8 bit count)
  • Starts with a 0% PWM ratio.

void manage_time_base (void)
 manage_time_base Should be executed in background to generate a non critical time base. Time base counter should be decremented each 32µs on Timer0 overflow. When Time base counter reaches 0, one second has elapsed. A flag is set and counter is set again to its init value.

Variables

SoftTimer_t time_count_1s
 variable used to decrement to zero each elapsed second


Function Documentation

void Timer0_start ( void   ) 

Timer0_start configures timer 0 for PWM on Output compare 0 B Configures timer as following:

Definition at line 52 of file Timer0_PWM.c.

References TIMER0_SET_OC0B_PWM.

Referenced by main().

00053 {
00054   // clear output compare pin at OCR0B compare match, set at TOP (0xFF) 
00055   TCCR0A = (1<<COM0B1) | (1<<WGM01) | (1<<WGM00);   
00056   // Set Fast PWM mode with output compare : Wave form generation Fast PWM, 
00057   // top counter value 0xFF, clk/1 prescaler -> Overflow (PWM) period = 32µs
00058   TCCR0B = (1<<CS00);
00059   // PWM ratio set to zero
00060   TIMER0_SET_OC0B_PWM (0x00);
00061 }

void manage_time_base ( void   ) 

manage_time_base Should be executed in background to generate a non critical time base. Time base counter should be decremented each 32µs on Timer0 overflow. When Time base counter reaches 0, one second has elapsed. A flag is set and counter is set again to its init value.

Definition at line 71 of file Timer0_PWM.c.

References SoftTimer_t::count, ONE_SECOND, SoftTimer_t::ovf, and time_count_1s.

Referenced by main().

00072 {
00073   if (TIFR0 & (1<<TOV0))          // Has Timer 0 overflowed ?
00074   {
00075     if (time_count_1s.count > 0)
00076       time_count_1s.count--;
00077     else
00078     {
00079       time_count_1s.count = ONE_SECOND;  // 31250 * 32µs --> 1s period counter
00080       time_count_1s.ovf = true;
00081     }
00082     TIFR0 |= (1<<TOV0);           // Clear Timer 0 overflow flag bit
00083   }
00084 }


Variable Documentation

SoftTimer_t time_count_1s

variable used to decrement to zero each elapsed second

Definition at line 41 of file Timer0_PWM.c.

Referenced by display_defaults(), manage_time_base(), and refresh_ATA6824_watchdog().


Generated on Wed Mar 14 10:53:33 2007 for Mega88_&_ATA6824_High_temperature_H-Bridge_system by  doxygen 1.4.7