智能车制作

标题: 新手不知道怎么把电机动起来~~求救呀!!想了一个晚上了大神救救我吧配图 [打印本页]

作者: 夕阳过后    时间: 2012-11-8 09:01
标题: 新手不知道怎么把电机动起来~~求救呀!!想了一个晚上了大神救救我吧配图
bts7960是接pp0pp2pp4pp7.怎么才能让电机动起来呢?


#include <hidef.h> /* common defines and macros */
#include "derivative.h" /* derivative-specific definitions */
#pragma LINK_INFO DERIVATIVE "mc9s12xs128"
//--------------初始化函数----------------//
//-----时钟初始化程序--------//
void PLL_Init(void) //PLLCLK=2*OSCCLK*(SYNR+1)/(REFDV+1)
{ //锁相环时钟=2*16*(2+1)/(1+1)=48MHz
REFDV=1; //总线时钟=48/2=24MHz
SYNR=2;
while(!(CRGFLG&0x08));
CLKSEL=0x80; //选定锁相环时钟
}
//-----PWM 初始化程序------//
void PWM_Init(void)
{
PWME_PWME0=0x00; // Disable PWM 禁止
PWMPRCLK=0x33; // 0011 0011 A=B=24M/8=3M 时钟预分频寄存器设置
PWMSCLA=150; // SA=A/2/150=10k 时钟设置
PWMSCLB=150; // SB=B/2/15 =100k 时钟设置
PWMCLK_PCLK3=1; // PWM3-----SB 时钟源的选择
PWMPOL_PPOL3=1; // Duty=High Time 极性设置
PWMCAE_CAE3=0; // Left-aligned 对齐方式设置
PWMCTL=0x00; // no concatenation 控制寄存器设置
PWMPER0=200; // Frequency=SB/100=1K 周期寄存器设置
PWMDTY0=25; // Duty cycle = 50% 占空比寄存器设置
PWME=0x95; // Enable PWM 使能
}
//-----------------主函数--------------------//
void main(void)
{
/* put your own code here */
PLL_Init();
PWM_Init() ;
  EnableInterrupts;
  for(;;)
  {    ;
  }
/* please make sure that you never leave main */
}

作者: 赵彤山东    时间: 2012-11-8 16:21
俺用的mos管的,这个不懂,但是你的pwm有错吗
作者: HHHvictor    时间: 2012-11-9 11:33
这个占空比是50%吗?




欢迎光临 智能车制作 (http://dns.znczz.com/) Powered by Discuz! X3.2