Timer0_PWM.h

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.h
00011 ** Description : High temperature DC motor control
00012 **                PWM output compare OC0B pluged on ATA6824 PWM input command
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 
00031 #ifndef _TIMER0_PWM_H
00032 #define _TIMER0_PWM_H
00033 /*_____ I N C L U D E S ____________________________________________________*/
00034 
00035 /*_____ M A C R O S ________________________________________________________*/
00036 
00037 #define TIMER0_SET_OC0B_PWM(val)          (OCR0B = val)
00038 
00039 /*_____ D E F I N I T I O N S ______________________________________________*/
00040 
00042 typedef struct{
00043   U16 count :15;      
00044   U16 ovf   :1;       
00045 }SoftTimer_t;
00046                 
00047 #define WD_TIME_TRIG  320     // 320 * 32µs --> 10.24ms, half of the WD refresh period. 
00048                               // A 51 Kohms resistor is pluged to the ATA6824 Rwd pin
00049                               // Which lead to a typical 25ms Twd (see ATA6824 datasheet §5.3)
00050                               // A rising edge on the WD trigger pin should occur 
00051                               // in t2 open window, which is: (25ms - 9.61ms) < Trigger < 25ms
00052 
00053 #define ONE_SECOND    31250   // 31250 * 32µs --> 1s period counter
00054 
00055 #define DISABLE_OCB0()    (TCCR0A &= ~(1<<COM0B1) | (1<<COM0B0))
00056 #define RE_ENABLE_OCB0()  (TCCR0A |=  (1<<COM0B1))
00057 
00058 /*_____ P R O T O T Y P E S - D E C L A R A T I O N ________________________*/
00059 
00060 void Timer0_start(void);              // Start Timer 0 for PWM using Output compare, 32µs overflow period
00061 void manage_time_base(void);          // Check Timer 0 overflows to manage time base 
00062 
00063 /*_____ G L O B A L S ______________________________________________________*/
00064 
00065 extern SoftTimer_t time_count_1s;     // variable used to decrement to zero each elapsed second
00066 #endif //_TIMER0_PWM_H

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