I want to drive a BLDC motor, i use ATMEGA32 as CPU of controller , i have a problem in reading hall effect sensor from BLDC motor
this is my code :
DDRB=(1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5);
DDRD=(0<<0)|(0<<1)|(0<<2)|(0<<3);
PORTD=(1<<0)|(1<<1)|(1<<2)|(1<<3);
PORTB as OUTPUT and PORTD as INPUT this is main program :
if (~(PORTD &(1<<0)) && PORTD &(1<<1) && ~(PORTD &(1<<2))) /// 0 1 0
{
PORTB=(1<<0)|(0<<1)|(0<<2)|(1<<3)|(0<<4)|(0<<5);
}
else if (~(PORTD &(1<<0)) && PORTD &(1<<1) && PORTD &(1<<2)) /// 0 1 1
{
PORTB=(0<<0)|(0<<1)|(0<<2)|(1<<3)|(0<<4)|(1<<5);
}
...........
my answer is this program cannot read logic zero (0) from hall effect sensor so BLDC cannot run well, how to read multiple input in AVR ATMEGA32 ? i use Codeblock and winavr....
Thank you very much