@@ -60,14 +60,16 @@ int main(void)
6060 DDRD = 0b00000000 ; // Input DIR >mega 20 , 19 , 18 = PD1 , PD2 , PD3
6161 EICRA |= 1 << ISC10 | 1 << ISC20 | 1 << ISC30 ; // Trigger on any edge
6262 EIMSK |= 1 << INT1 | 1 << INT2 | 1 << INT3 ;
63+ // INT1 >> yellow || INT2 << green || INT3 blue
64+
6365 //you can put INT0 for fault Input
6466
6567 // Configure Timer1 PWM pin and the enable pins
6668
6769 // Configure Port I/O as Timer PWM output pin
6870 // PWM HS> (pin 11 in Arduino mega) OCR1A PB5
6971 DDRB |= 1 << PINB5 ;
70- //HS en PL 2,4,6 LS en PL 1,3,5
72+ //HS en PL 2,4,6 LS en PL 1,3,5 ||mega HS >> 47, 45, 43 || LS >> 48, 46, 44
7173 DDRL = 0b01111110 ;
7274
7375 TCCR1A |= 1 << WGM11 ;
@@ -84,6 +86,7 @@ int main(void)
8486 //Init_ADC()
8587 ADMUX |= 1 << REFS0 ; //AVCC with external capacitor at AREF pin, MUX = 0000 >ADC0 >PF0>A0
8688 ADCSRA |= 1 << ADEN | 1 << ADPS2 ; //N = 16
89+ int adc10 ;
8790
8891 // Variable Initializations
8992 PWM_Update_Counter = 0x0 ;
@@ -107,7 +110,8 @@ int main(void)
107110
108111 ADCSRA |= 1 << ADSC ;
109112 while (ADCSRA & (1 << ADSC ));
110- Temp_DutyCycle = (ADC /1024.0 ) * (int )(TIMER_PWM_PERIOD * 0.99 );
113+ adc10 = ADC ;
114+ Temp_DutyCycle = (adc10 /1024.0 ) * (int )(TIMER_PWM_PERIOD * 0.99 );
111115
112116 if (Temp_DutyCycle < MIN_PWM_DUTYCYCLE )
113117 Desired_PWM_DutyCycle = MIN_PWM_DUTYCYCLE ; // < Min DutyCycle %age - latch to min value, 1023
@@ -126,7 +130,8 @@ void Start_Motor(void)
126130//Start_ADC_Conversion();
127131ADCSRA |= 1 << ADSC ;
128132while (ADCSRA & (1 << ADSC ));
129- Desired_PWM_DutyCycle = (ADC /1024.0 ) * (int )(TIMER_PWM_PERIOD * 0.99 );
133+ int adc10 = ADC ;
134+ Desired_PWM_DutyCycle = (adc10 /1024.0 ) * (int )(TIMER_PWM_PERIOD * 0.99 );
130135
131136// Read Hall inputs
132137Hall_IN = ((PIND & 0b00001110 ) >> 1 );
0 commit comments