Hi all!
Hope you are all well!
I’m playing with the Pololu MD01B H-Bridge with my Sam7x256 (using crossworks) and I seem to be getting stuck! I had this working with my Ardino just fine, but lost my machine (ie. all my code etc) and cannot seem to make it work again using the ARM7 this time…
All I want to do it make the motor spin…
Here is my sample code…I’m sure I am doing something stupid!
Any pointers would be greatly appreciated!
~Kam (^8*
// at91sam7x256 using Crossworks on a Olimex SAM7-EX256 board
// hbridge
//#define hb_INa (1<<27) // PB27
//#define hb_ENa (1<<28) // PB28
//#define hb_PWM (1<<29) // PB29
//#define hb_INb (1<<30) // PB30
//#define hb_ENb (1<<23) // PB23
// test for Pololu MDO1B h-bridge
void testMotor()
{
// configure port B
pPIOB->PIO_PER = hb_INa | hb_INb | hb_ENa | hb_ENb | hb_PWM;
pPIOB->PIO_OER = hb_INa | hb_INb | hb_ENa | hb_ENb | hb_PWM;
pPMC->PMC_PCER = 1 << AT91C_ID_PIOB; // enable the clock of the PIO
// what I now want to do is set it up as
//
// INa=high
// INb=low
// ENa=high
// ENb=high
// PWM=high (but we toggle)
// turn on INa, ENa, ENb, PWM (make high)
pPIOB->PIO_SODR=hb_INa | hb_ENa | hb_ENb | hb_PWM;
// turn off INb (make low)
pPIOB->PIO_CODR=hb_INb;
while(1)
{
// delay for some time
for(int x=0; x<500000; x++)
{
x=x+1;
x=x-1;
}
// toggle PWM bit
if((pPIOB->PIO_ODSR & hb_PWM) == hb_PWM)
{
pPIOB->PIO_CODR=hb_PWM;
}
else
{
pPIOB->PIO_SODR=hb_PWM;
}
}
}