Timer0_PWM.c

Go to the documentation of this file.
00001 /*
00002 **
00003 ****************************************************************************
00004 **
00005 **
00006 **             Copyright (c) 2007 - Atmel Corporation
00007 **             Proprietaty Information
00008 **
00009 ** Project     : ATMEGA88 + ATA6824 High Temperature H-bridge System
00010 ** Module      : Timer0_PWM.c
00011 ** Description : High temperature DC motor control. Timer0 generates PWM
00012 **                To be used with "High temperature H-bridge System" board
00013 **
00014 ** Version :     Date:         Author:      Comment:
00015 **    1.0        26.01.2007    F.G.          Creation 
00016 **
00017 ** LICENSE -
00018 **
00019 ** ATMEL - 2007
00020 ** All software programs are provided 'as is' without warranty of any kind:
00021 ** Atmel does not state the suitability of the provided materials for any
00022 ** purpose. Atmel hereby disclaim all warranties and conditions with regard
00023 ** to the provided software, including all implied warranties, fitness for
00024 ** a particular purpose, title and non-infringement.In no event will Atmel
00025 ** be liable for any indirect or consequential damages or any damages
00026 ** whatsoever resulting from the usage of the software program.
00027 ****************************************************************************
00028 **
00029 */
00030 /*_____ I N C L U D E S ____________________________________________________*/
00031 #include "config.h"
00032 #include "Timer0_PWM.h"
00033 
00034 /*_____ M A C R O S ________________________________________________________*/
00035 
00036 /*_____ D E F I N I T I O N S ______________________________________________*/
00037 
00038 /*_____ P R O T O T Y P E S - D E C L A R A T I O N ________________________*/
00039 
00040 /*_____ G L O B A L S ______________________________________________________*/
00041 SoftTimer_t time_count_1s;    
00042 
00052 void Timer0_start(void)
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 }
00062 
00063 
00064 
00071 void manage_time_base(void)
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 }
00085 
00086 

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