📄 const.h
字号:
/***********************************************************************
* HEADER_START *
* *
* Name: const.h *
* Project: Sensorless BLDC Motor HC08 *
* Description: main constant header file, and *
* pwm frequency current sampling period setting *
* Processor: HC08MR32/24 *
* HW: MC68HC908MR32 MC BOARD 01-RE10144W01 REV B *
* Crystal 4 MHz,Bus freq 8MHz *
* Revision: 0.1 *
* Date: 6th Decembert 2004 *
* Compiler: METROWERKS ANSI-C/cC++ Compiler for HC08 *
* V-5.0.12 ICG *
* Author: Libor Prokop *
* Company: Motorola SPS *
* Roznov System Application Laboratory *
* Roznov pod Radhostem, Czech Republic *
* Security: General Business Information *
* Note: DEFAULT SW SETTING. Only pwm frequency and *
* current sampling period may be set in this file*
* For SW adaptation do changes *
* in const_cust.h *
* *
* =================================================================== *
* Copyright (c): MOTOROLA Inc.,2004, All rights reserved. *
* *
* =================================================================== *
* THIS SOFTWARE IS PROVIDED BY MOTOROLA RSAL "AS IS" AND ANY *
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MOTOROLA RSAL OR *
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT *
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; *
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, *
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED *
* OF THE POSSIBILITY OF SUCH DAMAGE. *
* =================================================================== *
*
* HEADER_END
*/
#ifndef _CONST_H_
#define _CONST_H_ /* if const.h not included, include */
/* 平路无风,80瓦
克服风阻 120瓦
25公里 160瓦
*/
#include "Predef.h"
/******************************************************************************
* N O T E: *
* FOR SW ADAPTATION TO A MOTOR DO CHANGES in const_cust.h *
* *
******************************************************************************/
/******************************************************************************
* N O T E: *
* *
* FOR CHANGING OF PWM FREQUENCY OR CURRENT SAMPLING PERIOD *
* DO CHANGES BELOW: *
* CAN_CHANGE_FPWM_n -label for definitions which should be *
* corrected, when pwm frequency changing *
* CAN_CHANGE_PERCURSAMP_n-label for definitions which should be *
* corrected, when changing Current Sampling Period *
* *
******************************************************************************/
/******************************************************************************/
/* D E F I N E S */
/******************************************************************************/
/******************************************************************************
* Custommer wants to change motor PWM frequency *
******************************************************************************/
/************** General Purpose Registers constants ***************************/
#define I_CONFIG1 0x01 /* 0x01 MOR register initialization const.
COPRS = 0
LVISTOP = 0
LVIRSTD = 0
LVIPWRD = 0
LVI5OR3 = 0
SSREC = 0
STOP = 0
COPD = 1 */
/************** Oscillator Trim Register (OSCTRIM) ***************************/
#define I_OSCTRIM 0x80 /* The reset value is $50, which sets
the frequency to 12.8 MHz
(3.2 MHz bus speed) ±25%. */
/* PWM frequency */
#define TIMER_CLOCK_HZ 1600000 /* 3.2MHz */
#define PWM_FREQ_HZ 16000 /* 16kHz */
#define MCPWM_MODULUS TIMER_CLOCK_HZ/PWM_FREQ_HZ /* define PWM frequency */
/*************** system coniguration value ************************************/
#define I_DDRA 0x23 /* PTA0 = ctrl2 output 1
PTA1 = ctrl1 = output 1
PTA2 = Test input 0
PTA3 = Switch input 0
PTA4 = Current A/D2 input 0
PTA5 = N/A output 1
PTA6 = No Use 0
PTA7 = No Use 0
*/
/* In PTB PTB0-PTB5 serve as Hall output, PTA3, PTB6, PTB7 as Hall Input */
#define I_DDRB 0x7f /* PTB0 = a output 1
PTB1 = b output 1
PTB2 = c output 1
PTB3 = d output 1
PTB4 = e output 1
PTB5 = f output 1
PTB6 = g output 1
PTB7 = PowerOn input 0
*/
/*|Hallc|Hallb|Cb|Ct|Bb|Bt|Ab|At|*/
#define I_PORTA 0x00
#define I_ADICLK 0x20 /* ADCLK reg. initialization const.
ADIV = 001 ADC fad=6MHz=fop/4
when fop=12.6MHz
*/
#define I_PTAPUE 0x04
#define I_PTBPUE 0x80
/************** Initial values and constants for Timers ****************/
#define I_TSC 0x71 /* %00000100
|TOF|TOIE|TSTOP|TRST|R|PS2|PS1|PS0|
0 1 1 1 0 0 0 1
fbus/2 */
#define I_TSC0 0x10 /* %01011100
|CH0F|CH0IE|MS0B|MS0A|ELS0B|ELS0A|TOV0|CH0MAX|
0 0 0 1 0 0 0 0
enable TIMA ch #1 interrupt,
set TIMA ch #1 as Output Compare,
clear output on compare
Set Output on Compare,
unbuffered PWM
toggle overflow*/
/************** Initial values and constants for A/D channel ****************/
#define C_Current 0x22
#define C_Peak 0x23
/******************** Port Definition **************************************/
#define CTRL0 PTA0
#define CTRL1 PTA1
#define MODETEST PTA2
//#define POWERON PTA3
#define POWERON PTB7
/******************** INITIALIZATION OF VARIABLES *************************/
#define _100ms 1600
#define _125ms 2000
#define _62p5ms 1000
#define _400ms 6400
#define _1s 16000
#define _2s 32000
#define _3s 48000
#define _4s 64000
/********************* Delay **********************************************/
#define PORTDELAY 10
#define PORTDELAY_BEG 100
/*******************End of Speed CONSTS and Calculation **************************/
#endif /* _CONST_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -