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 : ATA6824_defs.c 00011 ** Description : High temperature DC motor control. 00012 ** To be used with "High temperature H-bridge System" board 00013 ** 00014 ** Version : Date: Author: Comment: 00015 ** 1.0 05.03.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 "ATA6824_defs.h" 00033 #include "Timer0_PWM.h" // Generates a time base required by WD refresh routine 00034 00035 /*_____ M A C R O S ________________________________________________________*/ 00036 00037 /*_____ D E F I N I T I O N S ______________________________________________*/ 00038 00039 /*_____ P R O T O T Y P E S - D E C L A R A T I O N ________________________*/ 00040 00041 /*_____ G L O B A L S ______________________________________________________*/ 00042 00043 ATA6824_diag_mgt_t ATA6824_diag_mgt; //<! Allows to manage failures 00044 00045 00046 00056 void refresh_ATA6824_watchdog(void) 00057 { 00058 static unsigned int last_count=0; // remembers the last WD trigger instant 00059 signed int dif; 00060 00061 // Compute elapsed time since the last WD trigger has occured 00062 dif = last_count - (U16)(time_count_1s.count); 00063 00064 if (dif<0) 00065 {dif = dif + ONE_SECOND; }; // take care of time count overflows 00066 00067 // Check the elapsed time since the last WD trigger 00068 if (dif > WD_TIME_TRIG) 00069 { 00070 // Toggle the Watchdog trigger pin when half of the period has elapsed 00071 TOGGLE_WD_TRIG(); 00072 last_count = time_count_1s.count; // remember the last WD trigger instant 00073 } 00074 } 00075 00076 00077 00083 void Diag_inputs_ISR_init(void) 00084 { 00085 /*init PCINT1 Pin change interrupt initialisation */ 00086 // PCINT14...8 interrupt pins enabled 00087 PCICR |= 1 << PCIE1; 00088 // PCINT10/11/12 interrupt pin are enabled 00089 PCMSK1 |= (1 << PCINT12) | (1 << PCINT11) | (1 << PCINT10); 00090 } 00091 00092 00093 00100 #if defined(__ICCAVR__) //IAR COMPILER USED 00101 #pragma vector= PCINT1_vect //Pin Change interrupt 10 vector for ATmega88 00102 __interrupt void Diag123_ISR (void) 00103 #elif defined (__AVR__) // Avr-gcc compiler used 00104 ISR(PCINT1_vect) 00105 #endif 00106 { 00107 if (GET_DG1_STATUS()) 00108 ATA6824_diag_mgt.dg1 = LATCHED_FAILURE; // latch Short-circuit failure 00109 00110 if (GET_DG2_STATUS()) 00111 ATA6824_diag_mgt.dg2 = LATCHED_FAILURE; // latch Charge pump or voltage failure 00112 00113 if (GET_DG3_STATUS()) 00114 ATA6824_diag_mgt.dg3 = WARNING; // signal Over-temperature warning 00115 else 00116 ATA6824_diag_mgt.dg3 = NO_FAILURE; // Clear Over-temperature warning 00117 } 00118 00119 00120 00124 void clear_faults(void) 00125 { 00126 if ( (ATA6824_diag_mgt.dg1 == LATCHED_FAILURE) && (!GET_DG1_STATUS()) ) 00127 { 00128 // Unlatch short-cicuit detected if no more present 00129 ATA6824_diag_mgt.dg1 = NO_FAILURE; 00130 } 00131 00132 if ( (ATA6824_diag_mgt.dg2 == LATCHED_FAILURE) && (!GET_DG2_STATUS()) ) 00133 { 00134 // Unlatch pump charge failure, undervoltage or overvoltage if no more present 00135 ATA6824_diag_mgt.dg2 = NO_FAILURE; 00136 } 00137 }
1.4.7