mc_drv.h File Reference

#include "config.h"

Include dependency graph for mc_drv.h:

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

Go to the source code of this file.

Defines

#define BUSY   1
#define Clear_Port_Q1()   (PORTD &= ( ~(1<<PORTD0)))
#define Clear_Port_Q2()   (PORTB &= ( ~(1<<PORTB7)))
#define Clear_Port_Q3()   (PORTC &= ( ~(1<<PORTC0)))
#define Clear_Port_Q4()   (PORTB &= ( ~(1<<PORTB6)))
#define Clear_Port_Q5()   (PORTB &= ( ~(1<<PORTB0)))
#define Clear_Port_Q6()   (PORTB &= ( ~(1<<PORTB1)))
#define CONV_CURRENT   2
#define CONV_INIT   0
#define CONV_POT   1
#define Disable_IT_comparator0()   AC0CON &= ~(1<<AC0IE);
#define Disable_IT_comparator1()   AC1CON &= ~(1<<AC1IE);
#define Disable_IT_comparator2()   AC2CON &= ~(1<<AC2IE);
#define Disable_IT_comparator2_1_0()
#define Disable_over_current()
#define Enable_IT_comparator0()
#define Enable_IT_comparator1()
#define Enable_IT_comparator2()
#define Enable_IT_comparator2_1_0()
#define Enable_over_current()
#define Force_CMP0_high()
#define Force_CMP0_low()
#define Force_CMP1_high()
#define Force_CMP1_low()
#define Force_CMP2_high()
#define Force_CMP2_low()
#define FREE   0
#define HALL_A()   (PCINT1_vect)
#define HALL_B()   (PCINT0_vect)
#define HALL_SENSOR_VALUE()
#define Release_CMP0()
#define Release_CMP1()
#define Release_CMP2()   DDRD &= ~((1<<DDD6)|(1<<DDD5));
#define Set_none()
#define Set_Port_Q2()   (PORTB |= (1<<PORTB1))
#define Set_Port_Q4()   (PORTB |= (1<<PORTB6))
#define Set_Port_Q6()   (PORTB |= (1<<PORTB7))
#define Set_Q1Q4()
#define Set_Q1Q6()
#define Set_Q3Q2()
#define Set_Q3Q6()
#define Set_Q5Q2()
#define Set_Q5Q4()
#define STATE_CMP0   0
#define STATE_CMP1   1
#define STATE_CMP2   2
#define STATE_CW001   7
#define STATE_CW010   5
#define STATE_CW011   6
#define STATE_CW100   3
#define STATE_CW101   8
#define STATE_CW110   4

Functions

void mc_ADC_Scheduler (void)
 Launch the scheduler for the ADC.
void mc_disable_during_inrush (void)
 the purpose of this function is to disable
the overcurrent detection during startup (inrush current)

void mc_duty_cycle (U8 level)
 Set the duty cycle values in the PSC according to the value calculate by the regulation loop.
void mc_estimation_speed (void)
 estimation speed
U8 mc_Get_Current (void)
Motor_Position mc_get_hall (void)
 Get the value of hall sensors (1 to 6).
U8 mc_Get_Potentiometer (void)
void mc_init_HW (void)
 mc_init_HW : Hardware Initialization
void mc_init_timer0 (void)
 Timer 0 Configuration The timer 0 is used to generate an IT when an overflow occurs.
void mc_init_timer1 (void)
 timer 1 Configuration
void mc_inrush_task (void)
 the purpose of this function is to manage the delay
used when the overcurrent detection is disabled

void mc_switch_commutation (Motor_Position position)
 Set the Switching Commutation value on outputs.
void PSC_Init (void)
 PSC Init : Initialize the PSC according to the settings in config.h.
void start_running_phase (void)


Define Documentation

#define BUSY   1

Definition at line 295 of file mc_drv.h.

Referenced by mc_ADC_Scheduler().

 
#define Clear_Port_Q1 (  )     (PORTD &= ( ~(1<<PORTD0)))

Definition at line 51 of file mc_drv.h.

 
#define Clear_Port_Q2 (  )     (PORTB &= ( ~(1<<PORTB7)))

Definition at line 54 of file mc_drv.h.

 
#define Clear_Port_Q3 (  )     (PORTC &= ( ~(1<<PORTC0)))

Definition at line 50 of file mc_drv.h.

 
#define Clear_Port_Q4 (  )     (PORTB &= ( ~(1<<PORTB6)))

Definition at line 53 of file mc_drv.h.

 
#define Clear_Port_Q5 (  )     (PORTB &= ( ~(1<<PORTB0)))

Definition at line 49 of file mc_drv.h.

 
#define Clear_Port_Q6 (  )     (PORTB &= ( ~(1<<PORTB1)))

Definition at line 52 of file mc_drv.h.

#define CONV_CURRENT   2

Definition at line 292 of file mc_drv.h.

Referenced by ADC_end_of_conversion(), and mc_ADC_Scheduler().

#define CONV_INIT   0

Definition at line 290 of file mc_drv.h.

Referenced by mc_ADC_Scheduler().

#define CONV_POT   1

Definition at line 291 of file mc_drv.h.

Referenced by ADC_end_of_conversion(), and mc_ADC_Scheduler().

 
#define Disable_IT_comparator0 (  )     AC0CON &= ~(1<<AC0IE);

Definition at line 270 of file mc_drv.h.

 
#define Disable_IT_comparator1 (  )     AC1CON &= ~(1<<AC1IE);

Definition at line 273 of file mc_drv.h.

 
#define Disable_IT_comparator2 (  )     AC2CON &= ~(1<<AC2IE);

Definition at line 276 of file mc_drv.h.

 
#define Disable_IT_comparator2_1_0 (  ) 

Value:

AC0CON &= ~((1<<AC0IE)); \
    AC1CON &= ~((1<<AC1IE)); \
    AC2CON &= ~((1<<AC2IE));

Definition at line 265 of file mc_drv.h.

Referenced by mc_comparator_0(), mc_comparator_1(), and mc_comparator_2().

 
#define Disable_over_current (  ) 

 
#define Enable_IT_comparator0 (  ) 

Value:

ACSR |= (1<<AC0IF);           \
    AC0CON |= (1<<AC0IE);

Definition at line 253 of file mc_drv.h.

Referenced by demag_interrupt().

 
#define Enable_IT_comparator1 (  ) 

Value:

ACSR |= (1<<AC1IF);           \
    AC1CON |= (1<<AC1IE);

Definition at line 257 of file mc_drv.h.

Referenced by demag_interrupt().

 
#define Enable_IT_comparator2 (  ) 

Value:

ACSR |= (1<<AC2IF);           \
    AC2CON |= (1<<AC2IE);

Definition at line 261 of file mc_drv.h.

Referenced by demag_interrupt().

 
#define Enable_IT_comparator2_1_0 (  ) 

Value:

ACSR |= (1<<AC2IF)|(1<<AC1IF)|(1<<AC0IF);  \
    AC0CON |= (1<<AC0IE); \
    AC1CON |= (1<<AC1IE); \
    AC2CON |= (1<<AC2IE);

Definition at line 247 of file mc_drv.h.

Referenced by demag_interrupt().

 
#define Enable_over_current (  ) 

 
#define Force_CMP0_high (  ) 

Value:

PORTD |= (1<<PORTD7);   /* PD7 = 1*/\
    PORTB &= ~(1<<PORTB2);  /* PB2 = 0*/\
    DDRD |= (1<<DDD7);                  \
    DDRB |= (1<<DDB2);

Definition at line 202 of file mc_drv.h.

 
#define Force_CMP0_low (  ) 

Value:

PORTD &= ~(1<<PORTD7);  /* PD7 = 0*/ \
    PORTB |= (1<<PORTB2);   /* PB2 = 1*/\
    DDRD |= (1<<DDD7);                 \
    DDRB |= (1<<DDB2);

Definition at line 208 of file mc_drv.h.

 
#define Force_CMP1_high (  ) 

Value:

PORTC |= (1<<PORTC6);   /* PC6 = 1*/\
    PORTB &= ~(1<<PORTB5);  /* PB5 = 0*/\
    DDRC |= (1<<DDC6);                  \
    DDRB |= (1<<DDB5);

Definition at line 218 of file mc_drv.h.

 
#define Force_CMP1_low (  ) 

Value:

PORTC &= ~(1<<PORTC6);  /* PC6 = 0*/ \
    PORTB |= (1<<PORTB5);   /* PB5 = 1*/\
    DDRC |= (1<<DDC6);                 \
    DDRB |= (1<<DDB5);

Definition at line 224 of file mc_drv.h.

 
#define Force_CMP2_high (  ) 

Value:

PORTD |= (1<<PORTD5);   /* PD5 = 1*/\
    PORTD &= ~(1<<PORTD6);  /* PD6 = 0*/\
    DDRD |= ((1<<DDD6)|(1<<DDD5));

Definition at line 234 of file mc_drv.h.

 
#define Force_CMP2_low (  ) 

Value:

PORTD &= ~(1<<PORTD5);  /* PD5 = 0*/ \
    PORTD |= (1<<PORTD6);   /* PD6 = 1*/\
    DDRD |= ((1<<DDD6)|(1<<DDD5));

Definition at line 239 of file mc_drv.h.

#define FREE   0

Definition at line 294 of file mc_drv.h.

Referenced by ADC_end_of_conversion(), and mc_ADC_Scheduler().

 
#define HALL_A (  )     (PCINT1_vect)

Definition at line 39 of file mc_drv.h.

 
#define HALL_B (  )     (PCINT0_vect)

Definition at line 40 of file mc_drv.h.

 
#define HALL_SENSOR_VALUE (  ) 

Value:

(Motor_Position)(\
    ( (PINC & (1<<PINC3)) >> PINC3 ) \
  | ( (PINB & (1<<PINB3)) >> 2 )     \
  | ( (PINB & (1<<PINB4)) >> 2 ))

Definition at line 43 of file mc_drv.h.

Referenced by mc_get_hall().

 
#define Release_CMP0 (  ) 

Value:

DDRD &= ~(1<<DDD7);                 \
    DDRB &= ~(1<<DDB2);

Definition at line 214 of file mc_drv.h.

 
#define Release_CMP1 (  ) 

Value:

DDRC &= ~(1<<DDC6);                 \
    DDRB &= ~(1<<DDB5);

Definition at line 230 of file mc_drv.h.

 
#define Release_CMP2 (  )     DDRD &= ~((1<<DDD6)|(1<<DDD5));

Definition at line 244 of file mc_drv.h.

 
#define Set_none (  ) 

Value:

POC = (0<<POEN0A)|(0<<POEN0B)|\
          (0<<POEN1A)|(0<<POEN1B)|\
          (0<<POEN2A)|(0<<POEN2B);\
    Clear_Port_Q2();                \
    Clear_Port_Q4();                \
    Clear_Port_Q6();                \
    Clear_Port_Q1();                \
    Clear_Port_Q3();                \
    Clear_Port_Q5();

Definition at line 60 of file mc_drv.h.

Referenced by mc_switch_commutation(), and thirty_degres_interrupt().

 
#define Set_Port_Q2 (  )     (PORTB |= (1<<PORTB1))

Definition at line 55 of file mc_drv.h.

 
#define Set_Port_Q4 (  )     (PORTB |= (1<<PORTB6))

Definition at line 56 of file mc_drv.h.

 
#define Set_Port_Q6 (  )     (PORTB |= (1<<PORTB7))

Definition at line 57 of file mc_drv.h.

 
#define Set_Q1Q4 (  ) 

Value:

PORTB &= ( ~((1<<PORTB1)|(1<<PORTB7)));\
    POC = (1<<POEN0A)|(1<<POEN0B)|\
          (0<<POEN1A)|(0<<POEN1B)|\
          (0<<POEN2A)|(0<<POEN2B);\
    PORTB |=   (1<<PORTB6);

Definition at line 107 of file mc_drv.h.

Referenced by mc_switch_commutation(), and thirty_degres_interrupt().

 
#define Set_Q1Q6 (  ) 

Value:

PORTB &= ( ~((1<<PORTB6)|(1<<PORTB7)));\
    POC = (1<<POEN0A)|(1<<POEN0B)|\
          (0<<POEN1A)|(0<<POEN1B)|\
          (0<<POEN2A)|(0<<POEN2B);\
    PORTB |=   (1<<PORTB1);

Definition at line 100 of file mc_drv.h.

Referenced by mc_switch_commutation(), and thirty_degres_interrupt().

 
#define Set_Q3Q2 (  ) 

Value:

PORTB &= ( ~((1<<PORTB1)|(1<<PORTB6)));\
    POC = (0<<POEN0A)|(0<<POEN0B)|\
          (1<<POEN1A)|(1<<POEN1B)|\
          (0<<POEN2A)|(0<<POEN2B);\
    PORTB |=   (1<<PORTB7);

Definition at line 93 of file mc_drv.h.

Referenced by mc_switch_commutation(), and thirty_degres_interrupt().

 
#define Set_Q3Q6 (  ) 

Value:

PORTB &= ( ~((1<<PORTB6)|(1<<PORTB7)));\
    POC = (0<<POEN0A)|(0<<POEN0B)|\
          (1<<POEN1A)|(1<<POEN1B)|\
          (0<<POEN2A)|(0<<POEN2B);\
    PORTB |=   (1<<PORTB1);

Definition at line 86 of file mc_drv.h.

Referenced by mc_switch_commutation(), and thirty_degres_interrupt().

 
#define Set_Q5Q2 (  ) 

Value:

PORTB &= ( ~((1<<PORTB1)|(1<<PORTB6)));\
    POC = (0<<POEN0A)|(0<<POEN0B)|\
          (0<<POEN1A)|(0<<POEN1B)|\
          (1<<POEN2A)|(1<<POEN2B);\
    PORTB |=   (1<<PORTB7);

Definition at line 79 of file mc_drv.h.

Referenced by mc_switch_commutation(), and thirty_degres_interrupt().

 
#define Set_Q5Q4 (  ) 

Value:

PORTB &= ( ~((1<<PORTB1)|(1<<PORTB7)));\
    POC = (0<<POEN0A)|(0<<POEN0B)|\
          (0<<POEN1A)|(0<<POEN1B)|\
          (1<<POEN2A)|(1<<POEN2B);\
    PORTB |=   (1<<PORTB6);

Definition at line 72 of file mc_drv.h.

Referenced by mc_switch_commutation(), and thirty_degres_interrupt().

#define STATE_CMP0   0

Definition at line 279 of file mc_drv.h.

#define STATE_CMP1   1

Definition at line 280 of file mc_drv.h.

#define STATE_CMP2   2

Definition at line 281 of file mc_drv.h.

#define STATE_CW001   7

Definition at line 286 of file mc_drv.h.

#define STATE_CW010   5

Definition at line 284 of file mc_drv.h.

#define STATE_CW011   6

Definition at line 285 of file mc_drv.h.

#define STATE_CW100   3

Definition at line 282 of file mc_drv.h.

#define STATE_CW101   8

Definition at line 287 of file mc_drv.h.

#define STATE_CW110   4

Definition at line 283 of file mc_drv.h.


Function Documentation

void mc_ADC_Scheduler ( void   ) 

Launch the scheduler for the ADC.

Postcondition:
Get results for Potentiometer and current values.

Definition at line 675 of file mc_drv.c.

References ADC_INPUT_AMP1, ADC_INPUT_ISRC, Adc_left_adjust_result, Adc_right_adjust_result, Adc_start_conv_channel, ADC_State, BUSY, CONV_CURRENT, CONV_INIT, CONV_POT, FREE, and State.

Referenced by main().

00676 {
00677   switch(State)
00678   {
00679   case CONV_INIT :
00680     ADC_State = FREE;
00681     State = CONV_CURRENT;
00682     break;
00683 
00684   case CONV_CURRENT :              /* previous state was CONV_CURRENT */
00685     if(ADC_State == FREE)
00686     {
00687       ADC_State = BUSY;
00688       State= CONV_POT;                        /* new state is CONV_POT */
00689       Adc_left_adjust_result();
00690       Adc_start_conv_channel(ADC_INPUT_ISRC); /* get POT on ISRC input */
00691     }
00692     break;
00693 
00694   case CONV_POT :                           /* previous state was CONV_POT */
00695     if(ADC_State == FREE)
00696     {
00697       ADC_State = BUSY;
00698       State = CONV_CURRENT;                   /* new state is CONV_CURRENT */
00699       Adc_right_adjust_result();
00700       Adc_start_conv_channel(ADC_INPUT_AMP1); /* get current on amplifier 1 */
00701     }
00702     break;
00703   }
00704 }

void mc_disable_during_inrush ( void   ) 

the purpose of this function is to disable
the overcurrent detection during startup (inrush current)

Definition at line 715 of file mc_drv.c.

References Disable_over_current, inrush_delay, inrush_mask_flag, and TRUE.

Referenced by mci_retry_run(), mci_run(), and ushell_task().

00716 {
00717   inrush_delay = (U16) 500;
00718   inrush_mask_flag = TRUE;
00719   Disable_over_current();
00720 }

void mc_duty_cycle ( U8  level  ) 

Set the duty cycle values in the PSC according to the value calculate by the regulation loop.

Definition at line 272 of file mc_drv.c.

References A_RA_VAL, B_RA_VAL, C_RA_VAL, DEADTIME, Psc_lock, Psc_set_module_A, Psc_set_module_B, Psc_set_module_C, and Psc_unlock.

Referenced by main(), mci_run(), and mci_stop().

00273 {
00274    U8 duty;
00275    duty = level;
00276 
00277 #if ((CURRENT_DECAY == SLOW_DECAY_SYNCHRONOUS)||(CURRENT_DECAY == FAST_DECAY_SYNCHRONOUS))
00278    U8 dutydt;   /* duty with dead time */
00279    if (duty >= DEADTIME) dutydt = duty - DEADTIME;
00280 #endif
00281    
00282    Psc_lock();
00283 
00284   // Duty = 0   => Duty Cycle   0%
00285   // Duty = 255 => Duty Cycle 100%
00286  
00287 #if (CURRENT_DECAY == FAST_DECAY)
00288    Psc_set_module_A(duty,A_RA_VAL,duty);
00289    Psc_set_module_B(duty,B_RA_VAL,duty);
00290    Psc_set_module_C(duty,C_RA_VAL,duty);
00291 #else
00292 #if ((CURRENT_DECAY == SLOW_DECAY_SYNCHRONOUS)||(CURRENT_DECAY == FAST_DECAY_SYNCHRONOUS))
00293    Psc_set_module_A(duty,A_RA_VAL,dutydt);
00294    Psc_set_module_B(duty,B_RA_VAL,dutydt);
00295    Psc_set_module_C(duty,C_RA_VAL,dutydt);
00296 #else
00297    Psc_set_module_A(duty,A_RA_VAL,0);
00298    Psc_set_module_B(duty,B_RA_VAL,0);
00299    Psc_set_module_C(duty,C_RA_VAL,0);
00300 #endif
00301 #endif
00302    
00303    Psc_unlock();
00304 }

void mc_estimation_speed ( void   ) 

estimation speed

Precondition:
configuration of timer 0
and define or not AVERAGE_SPEED_MEASURENT in config_motor.h
Postcondition:
new value for real speed

Definition at line 627 of file mc_drv.c.

References mc_set_measured_period(), stored_time, and timer0_ext.

Referenced by mc_comparator_1(), and mc_hall_a().

00628 {
00629   U16 actual_time;
00630   U16 period_motor;
00631 
00632   // Two 8 bits variables are use to simulate a 16 bits timer
00633   actual_time = (timer0_ext<<8) + TCNT0;
00634 
00635   if (actual_time > stored_time)
00636   {
00637     period_motor = actual_time - stored_time;
00638   }
00639   else
00640   {
00641     period_motor = (U16)65535 - stored_time + actual_time;
00642   }
00643 
00644   stored_time = actual_time;
00645 
00646   mc_set_measured_period(period_motor>>1);
00647 
00648 }

Here is the call graph for this function:

U8 mc_Get_Current ( void   ) 

Motor_Position mc_get_hall ( void   ) 

Get the value of hall sensors (1 to 6).

Parameters:
return an unsigned char value of hall sensor
Precondition:
configuration of port PB and PD
Postcondition:
new value of position

Definition at line 221 of file mc_drv.c.

References HALL_SENSOR_VALUE.

Referenced by mci_retry_run().

00222 {
00223   return HALL_SENSOR_VALUE();
00224 }

U8 mc_Get_Potentiometer ( void   ) 

void mc_init_HW ( void   ) 

mc_init_HW : Hardware Initialization

Postcondition:
initialization of hardware

Definition at line 90 of file mc_drv.c.

References Adc_config, Amp1_config, Comp_0_config, Comp_1_config, Comp_2_config, Dac_config, Dac_set_8_bits, IMAX, Init_PC7, mc_init_timer0(), mc_init_timer1(), PSC_Init(), Start_pll_64_mega, and Wait_pll_ready.

Referenced by mc_init().

00091 {
00092   // Output Pin configuration (used by PSC outputs)
00093   // PD0 => UH     PB7 => UL
00094   // PC0 => VH     PB6 => VL
00095   // PB0 => WH     PB1 => WL
00096 
00097   // Warning Output Low for MOSFET Drivers
00098   PORTB &= ~(1<<PORTB7 | 1<<PORTB6 | 1<<PORTB1 | 1<<PORTB0);
00099   PORTC &= ~(1<<PORTC0);
00100   PORTD &= ~(1<<PORTD0);
00101 
00102 /* to removed */
00103   PORTB |= (1<<PORTB4)|(1<<PORTB3); /* activate PB4 and PB3 pull up for sensorless debug */
00104   PORTC |= (1<<PORTC3); /* activate PC3 pull up for sensorless debug */
00105 
00106 /* pull up for external comparators : to remove when internal comp are used */ 
00107 #ifdef USE_INTERNAL_COMPARATORS
00108 #else
00109   PORTD |= (1<<PORTD7)|(1<<PORTD5);
00110   PORTC |= (1<<PORTC6);
00111 #endif
00112 
00113   // PORT B :
00114   DDRB = (1<<DDB7)|(1<<DDB6)|(1<<DDB1)|(1<<DDB0);
00115   // PORT C :
00116   DDRC = (1<<DDC0);
00117   // PORT D :
00118   DDRD = (1<<DDD0);
00119   // PORT E : /* to be removed */
00120   DDRE |= (1<<DDE2)|(1<<DDE1);
00121 
00122   Init_PC7(); /* PC7 is used to display the overcurrent */
00123 
00124   // Disable Digital Input for amplifier1
00125   DIDR1 = (1<<ADC9D)|(1<<ADC8D);
00126 
00127   // Disable Digital Input for comparators 0, 1 & 2  : to remove when external comp are used 
00128 #ifdef USE_INTERNAL_COMPARATORS
00129   DIDR0 = (1<<ADC6D)|(1<<ADC5D)|(1<<ADC3D)|(1<<ADC2D);
00130   DIDR1 = (1<<ADC10D)|(1<<ACMP0D);
00131 #endif
00132 
00133   // Select the Vref Source
00134 //  init_vref_source ();
00135 
00136 //  init_adc();
00137   Adc_config();
00138   Amp1_config();
00139   
00140   // Be careful : initialize DAC and Over_Current before PWM.
00141   // DAC is used for oevr current level
00142   Dac_config();
00143   /* set the overcurrent level */
00144   Dac_set_8_bits(IMAX);
00145     
00146   mc_init_timer0();
00147   mc_init_timer1();
00148 
00149   Comp_0_config();
00150   Comp_1_config();
00151   Comp_2_config();
00152   
00153   // Use PCINT14 to detect change on H2 sensor
00154   PCMSK0 = (1<<PCINT4)|(1<<PCINT3);
00155   PCMSK1 = (1<<PCINT11);
00156   PCICR = (1<<PCIE1)|(1<<PCIE0);
00157 
00158 //  Start_pll_32_mega(); // Start the PLL and use the 32 MHz PLL output
00159   Start_pll_64_mega(); // Start the PLL and use the 64 MHz PLL output
00160   Wait_pll_ready();
00161 
00162 
00163   // => PSCx_Init(Period_Half, Dutyx0_Half, Synchro, Dutyx1_Half)
00164   PSC_Init();
00165 
00166 }

Here is the call graph for this function:

void mc_init_timer0 ( void   ) 

Timer 0 Configuration The timer 0 is used to generate an IT when an overflow occurs.

Postcondition:
Timer0 initialized.

Definition at line 599 of file mc_drv.c.

Referenced by mc_init_HW().

00600 {
00601   TCCR0A = 0;
00602   TCCR0B = (0<<CS02)|(1<<CS01)|(1<<CS00); // prescaler /64 (4us)
00603   TIMSK0 = (1<<TOIE0);
00604 }

void mc_init_timer1 ( void   ) 

timer 1 Configuration

Definition at line 357 of file mc_drv.c.

Referenced by mc_init_HW().

00358 {
00359   TCCR1A = 0; //Normal port operation + Mode CTC
00360   TCCR1B = 1<<CS11 | 1<<CS10 ; // Mode CTC + prescaler 64 => T timer1 = 4µS
00361   TCCR1C = 0;
00362 }

void mc_inrush_task ( void   ) 

the purpose of this function is to manage the delay
used when the overcurrent detection is disabled

Definition at line 724 of file mc_drv.c.

References Enable_over_current, FALSE, inrush_delay, inrush_mask_flag, and TRUE.

00725 { 
00726   if (inrush_mask_flag == TRUE)
00727   {
00728     if (inrush_delay-- == 0)
00729     {
00730       inrush_mask_flag = FALSE;
00731       Enable_over_current();
00732     }
00733   }
00734 }

void mc_switch_commutation ( Motor_Position  position  ) 

Set the Switching Commutation value on outputs.

Parameters:
position (1 to 6) and direction (FORWARD or BACKWARD)

Definition at line 311 of file mc_drv.c.

References mci_get_motor_direction(), mci_motor_is_running(), motor_step, MS_001, MS_010, MS_011, MS_100, MS_101, MS_110, Set_none, Set_Q1Q4, Set_Q1Q6, Set_Q3Q2, Set_Q3Q6, Set_Q5Q2, and Set_Q5Q4.

Referenced by main(), mci_retry_run(), and mci_run().

00312 {
00313   // get the motor direction to commute the right switches.
00314   char direction = mci_get_motor_direction();
00315 
00316   // Switches are commuted only if the user start the motor
00317   if (mci_motor_is_running())
00318   {
00319     switch(position)
00320     {
00321     // cases according to rotor position
00322       case MS_001:  {Set_Q1Q6();motor_step=MS_001;}
00323                     break;
00324 
00325       case MS_101:  {Set_Q1Q4();motor_step=MS_101;}
00326                     break;
00327 
00328       case MS_100:  {Set_Q5Q4();motor_step=MS_100;}
00329                     break;
00330 
00331       case MS_110:  {Set_Q5Q2();motor_step=MS_110;}
00332                     break;
00333 
00334       case MS_010:  {Set_Q3Q2();motor_step=MS_010;}
00335                     break;
00336 
00337       case MS_011:  {Set_Q3Q6();motor_step=MS_011;}
00338                     break;
00339       default : break;
00340     }
00341   }
00342   else
00343   {
00344     Set_none(); // all switches are switched OFF
00345   }
00346 }

Here is the call graph for this function:

void PSC_Init ( void   ) 

PSC Init : Initialize the PSC according to the settings in config.h.

Definition at line 172 of file mc_drv.c.

References A_RA_VAL, A_SA_VAL, A_SB_VAL, B_RA_VAL, B_SA_VAL, B_SB_VAL, C_RA_VAL, C_SA_VAL, C_SB_VAL, Psc_config, Psc_config_input_0, Psc_config_input_1, Psc_config_input_2, PSC_INPUT_FILTER_ENABLE, PSC_INPUT_NO_ACTION, PSC_OVERLAP_ENABLE, Psc_run, Psc_set_module_A, Psc_set_module_B, Psc_set_module_C, Psc_set_register_RB, PSC_SYNCHRONOUS_OUTPUT_CONTROL, PSC_USE_COMPARATOR, PSC_USE_HIGH_LEVEL, PSC_USE_LOW_LEVEL, PSC_USE_PIN, and RB_VAL.

Referenced by mc_init_HW(), and mci_run().

void start_running_phase ( void   ) 

Definition at line 570 of file mc_drv.c.

References HIGH, LOW, TIMER1_AT_STARTUP_END, and top_average.

Referenced by main().

00571 {
00572   U16 top;
00573   TCCR1B = 0 ; // stop timer 1
00574   top_average = TIMER1_AT_STARTUP_END;
00575   top = (top_average >> 1);
00576   TCNT1H = HIGH(top);
00577   TCNT1L = LOW(top);
00578   OCR1AH = 0;
00579   OCR1AL = 0;
00580   top = top + (top_average >> 2);
00581   OCR1BH = HIGH(top);
00582   OCR1BL = LOW(top);
00583   TCCR1B = (1<<CS11) | (1<<CS10) ; // start timer 1
00584   TIFR1 = (1<<OCF1B) | (1<<OCF1A) | (1<<TOV1);
00585   TIMSK1= (1<<OCIE1B) | (1<<OCIE1A); // Output compare A Match interrupt Enable
00586 }


Generated on Wed Oct 22 15:04:00 2008 for AVR172 : Atmel BLDC control on ATAVRMC310 with ATmega32M1 by  doxygen 1.5.7.1