[mw_shl_code=c,true] [/mw_shl_code]
[mw_shl_code=c,true]#ifndef __MOTOR_H__
#define __MOTOR_H__
#include"sys.h"
#define M1_1 PCout(0)//8
#define M1_2 PCout(1)//9
#define M2_1 PCout(2)//10
#define M2_2 PCout(3)//11
void Motor_Init(void);
void Motor_Go(void);
#endif[/mw_shl_code]
[mw_shl_code=c,true]#include "motor.h"
#include "delay.h"
void Motor_Init(void)
{
RCC->APB2ENR|=1<<4;
GPIOC->CRL&=0XFFFF0000;
GPIOC->CRL|=0x00003333;
GPIOC->ODR|=1<<0;
GPIOC->ODR|=1<<1;
GPIOC->ODR|=1<<2;
GPIOC->ODR|=1<<3;
}
void Motor_Go(void)
{
M1_1=1;
M1_2=0;
M2_1=1;
M2_2=0;
}[/mw_shl_code]
这是电机的程序,连接上电源时不转,但是如果拔掉L298N的IN1(其中一个),电机就转了,输出的电压是有压差的,但是一连上杜邦线就没有压差了,这是为什么啊
|