I want to drive BlDC motor using L6234 Driver IC with help of Atmega 16 Controller. Logics for driving motor are given in the motor driver IC L6234 datasheet on page 9. Here is the link for datasheet. So, according to the datasheet I write a code to drive my motor. Here is my code:-
#define F_CPU 8000000UL
#include<avr/io.h>
#include<avr/interrupt.h>
#include<util/delay.h>
#define hall1 (PINC & 1<<1) // connect hall sensor1
#define hall2 (PINC & 1<<2) //connect hall sensor2
#define hall3 (PINC & 1<<3) //connect hall sensor3
void main()
{
DDRC=0XF0;
DDRB=0XFF; //output as In1=PB.0 ,In2=PB.1, In3=PB.2, En0=PB.3 ,En1=PB.4, En3=PB.5
while(1)
{
if((hall3==4)&(hall2==0)&(hall1==1)) // step1
{
PORTB=0X19;
}
if((hall3==0)&(hall2==0)&(hall1==1)) // step2
{
PORTB=0X29;
}
if((hall3==0)&(hall2==2)&(hall1==1)) // step3
{
PORTB=0X33;
}
if((hall3==0)&(hall2==2)&(hall1==0)) // step4
{
PORTB=0X1E;
}
if((hall3==4)&(hall2==2)&(hall1==0))// step5
{
PORTB=0X2E;
}
if((hall3==4)&(hall2==0)&(hall1==0))// step6
{
PORTB=0X34;
}
}
}
But when I run this code, my motor is not working. So, can any one tell me, where is the mistake in my code.