Timer0_PWM.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SoftTimer_t
 SoftTimer_t Used as a time based for general purpose non-critical use (like LED toggle). More...

Defines

#define TIMER0_SET_OC0B_PWM(val)   (OCR0B = val)
#define WD_TIME_TRIG   320
#define ONE_SECOND   31250
#define DISABLE_OCB0()   (TCCR0A &= ~(1<<COM0B1) | (1<<COM0B0))
#define RE_ENABLE_OCB0()   (TCCR0A |= (1<<COM0B1))

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


Define Documentation

#define TIMER0_SET_OC0B_PWM ( val   )     (OCR0B = val)

Definition at line 37 of file Timer0_PWM.h.

Referenced by main(), and Timer0_start().

#define WD_TIME_TRIG   320

Definition at line 47 of file Timer0_PWM.h.

Referenced by refresh_ATA6824_watchdog().

#define ONE_SECOND   31250

Definition at line 53 of file Timer0_PWM.h.

Referenced by manage_time_base(), and refresh_ATA6824_watchdog().

 
#define DISABLE_OCB0 (  )     (TCCR0A &= ~(1<<COM0B1) | (1<<COM0B0))

Definition at line 55 of file Timer0_PWM.h.

 
#define RE_ENABLE_OCB0 (  )     (TCCR0A |= (1<<COM0B1))

Definition at line 56 of file Timer0_PWM.h.


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