From d157b8edeea1d6e01a944529196b8d7e6ab529b3 Mon Sep 17 00:00:00 2001 From: Guillaume Chevillot Date: Wed, 13 Feb 2008 17:26:53 +0100 Subject: Add IT handlers for PWM rising and falling edge and for current limitation. --- analog/motor-power-avr/src/TODO.txt | 3 +-- analog/motor-power-avr/src/mp_pwm_LR_.h | 8 ++++++++ analog/motor-power-avr/src/mp_pwm_L_.c | 10 +++++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/analog/motor-power-avr/src/TODO.txt b/analog/motor-power-avr/src/TODO.txt index 2cd80ebe..2e64e761 100644 --- a/analog/motor-power-avr/src/TODO.txt +++ b/analog/motor-power-avr/src/TODO.txt @@ -1,7 +1,6 @@ TOTOlist pour le programe avr de motor-power -- Mettre a jour le module ADC -- attribuer les fonctions rise et fall aux interruptions TOV et OCR du timer +- corriger le switch case - peuafiner la boucle de mesure automatique de la température et de la batterie Tester : diff --git a/analog/motor-power-avr/src/mp_pwm_LR_.h b/analog/motor-power-avr/src/mp_pwm_LR_.h index 2798d810..416ef061 100644 --- a/analog/motor-power-avr/src/mp_pwm_LR_.h +++ b/analog/motor-power-avr/src/mp_pwm_LR_.h @@ -90,6 +90,14 @@ #define OCR_CurLim_L_ OCR1A #define OCR_CurLim_R_ OCR1B +// Vectors +#define ILIM_R_vect INT0_vect +#define ILIM_L_vect INT1_vect +#define L_OVF_vect TIMER0_OVF_vect +#define R_OVF_vect TIMER2_OVF_vect +#define L_COMP_vect TIMER0_COMP_vect +#define R_COMP_vect TIMER2_COMP_vect + // functions void init_timer_LR_(void); void init_curLim (void); diff --git a/analog/motor-power-avr/src/mp_pwm_L_.c b/analog/motor-power-avr/src/mp_pwm_L_.c index 085f2bcc..32c7c089 100644 --- a/analog/motor-power-avr/src/mp_pwm_L_.c +++ b/analog/motor-power-avr/src/mp_pwm_L_.c @@ -21,8 +21,8 @@ void init_pwm_L_ (void) { pwm_L_ = 0x00; } -// rising edge = timer overflow = TOV interrupt (TODO : à programmer) -void rise (void) { +// PWM rising edge on timer overflow IT +ISR(L_OVF_vect) { // programs the state which is ordered by the core code state_L_ = state_L_cmd; @@ -80,8 +80,8 @@ void rise (void) { } } -// falling edge = timer crossing OCR : OCn interrupt (TODO : à programmer) -void fall_L_ (void) { +// PWM falling edge on timer compare IT +ISR(L_COMP_vect) { // PC = PC + state_L_; TODO :saut calculé ? switch (state_L_) @@ -122,7 +122,7 @@ void fall_L_ (void) { // overcurrent detected by comparators -void ovc_L_ (void) { +ISR(ILIM_L_vect) { _L_AL_0; _L_AH_0; _L_BL_0; -- cgit v1.2.3