发现了个问题,PG8和PG9这2个IO,连续对这2个IO操作,
#define step_motor_x_dir (1<<8) //pg8,x轴电机方向
#define step_motor_x_dir_right() (*pPORTGIO_CLEAR|=step_motor_x_dir)
#define step_motor_x_dir_left() (*pPORTGIO_SET |=step_motor_x_dir)
#define step_motor_x_pulse (1<<9) //pg9,x轴电机输出脉冲
#define step_motor_x_pulse_off() (*pPORTGIO_CLEAR|=step_motor_x_pulse)
#define step_motor_x_pulse_on() (*pPORTGIO_SET |=step_motor_x_pulse)
//下面是BF504FGP8和GP9初始化
//第一个步进电机方向
*pPORTG_MUX |=1<<9;
*pPORTG_MUX |=1<<8;
*pPORTG_FER &=~step_motor_x_dir;
*pPORTGIO_DIR |= step_motor_x_dir;
step_motor_x_dir_left();
*pPORTG_MUX |=1<<11;
*pPORTG_MUX |=1<<10;
*pPORTG_FER &=~step_motor_x_pulse;
*pPORTGIO_DIR |= step_motor_x_pulse;
step_motor_x_pulse_off();
//这段放在定时器2中断里面执行....终端时间为1S.........
if(!led_flg)
{
led_off();
step_motor_x_dir_right();
step_motor_x_pulse_on();
led_flg=1;
}
else
{
led_on();
step_motor_x_dir_left();
step_motor_x_pulse_off();
led_flg=0;
}
这样操作,GP8就不会有输出,永远是低电平,
if(!led_flg)
{
led_off();
step_motor_x_dir_left();
step_motor_x_pulse_on();
led_flg=1;
}
else
{
led_on();
step_motor_x_dir_right();
step_motor_x_pulse_off();
led_flg=0;
}
这样操作就OK了..
不知道为啥,连续对GP8,GP9操作,如果2个连续设置为1,则可以正常输出,如果2个IO连续设置为0 1,或1 0,则不可以正常输出......