⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tpu_comm.c

📁 mpc564 时钟中断 时钟中断
💻 C
📖 第 1 页 / 共 2 页
字号:
	tpu_func( tpu, channel, TPU_FUNCTION_COMM);


/* Select Sensorless Match Mode for Host Sequence Register */	
	tpu_hsq(tpu, channel, COMM_SENSORLESS_MATCH);

/* Write NO_OF_PINS and COUNTER_ADDR to parameter RAM */
	no_pins_pram = (VUINT16)((no_of_pins<<8 & 0x0f00)|(counter_addr & 0x00ff));
	tpu->PARM.R[channel][COMM_NO_OF_PINS] = no_pins_pram;
	
/* Write UPDATE_PERIOD to parameter RAM */
	tpu->PARM.R[channel][COMM_UPDATE_PERIOD] = update_period;
	
/* Write state values to the parameter RAM */
	
	state_index = 0;	
	while(state_index < no_of_states)
	{
		tpu->PARM.R[(channel + 1 + state_index/8)][state_index - (state_index/8)*8] = comm_states[state_index];
		state_index++;
	}

/* Write NO_OF_STATES to parameter RAM */
	tpu->PARM.R[channel][COMM_NO_OF_STATES] = (no_of_states<<8) & 0xff00;

}



/*******************************************************************************
FUNCTION      : tpu_comm_write_upper
PURPOSE       : This function writes the upper angular boundary of the current commutation
		state to the parameter RAM.
INPUTS NOTES  : This function has 3 parameters:

                 *tpu    	- This is a pointer to the TPU3 module to use. It is of
                           	type TPU3_tag which is defined in m_tpu3.h

                 channel 	- This is the channel number of the master COMM
                          	channel.

                 upper 	- 	This value is the upper angular boundary of the current
                 		commutation state
                 	   
RETURNS NOTES : none

*******************************************************************************/

void tpu_comm_write_upper (struct TPU3_tag *tpu, UINT8 channel, INT16 upper)
{
	/* Write UPPER to parameter RAM */	
	tpu->PARM.R[channel][COMM_UPPER] = upper;
}



/*******************************************************************************
FUNCTION      : tpu_comm_write_lower
PURPOSE       : This function writes the lower angular boundary of the current commutation
		state to the parameter RAM.
INPUTS NOTES  : This function has 3 parameters:

                 *tpu    	- This is a pointer to the TPU3 module to use. It is of
                           	type TPU3_tag which is defined in m_tpu3.h

                 channel 	- This is the channel number of the master COMM
                          	channel.

                 lower 	- 	This value is the lower angular boundary of the current
                 		commutation state
                 	   
RETURNS NOTES : none

*******************************************************************************/

void tpu_comm_write_lower (struct TPU3_tag *tpu, UINT8 channel, INT16 lower)
{
	/* Write LOWER to parameter RAM */
	tpu->PARM.R[channel][COMM_LOWER] = lower;
}



/*******************************************************************************
FUNCTION      : tpu_comm_write_offset
PURPOSE       : This function writes the offset value to the parameter RAM to advance or
		retard the state switching angle when COMM is used in sensorless mode.
INPUTS NOTES  : This function has 3 parameters:

                 *tpu    	- This is a pointer to the TPU3 module to use. It is of
                           	type TPU3_tag which is defined in m_tpu3.h

                 channel 	- This is the channel number of the master COMM
                          	channel.

                 offset 	- This value advances or retards the the state switching
                 		angles when COMM is used in sensorless mode.
                 	   
RETURNS NOTES : none

*******************************************************************************/

void tpu_comm_write_offset (struct TPU3_tag *tpu, UINT8 channel, INT16 offset)
{
	/* Write OFFSET to parameter RAM */	
	tpu->PARM.R[channel][COMM_OFFSET] = offset;
}



/*******************************************************************************
FUNCTION      : tpu_comm_get_state_no
PURPOSE       : This function returns the value of the current state_no held in the 
		parameter RAM of COMM function master channel
INPUTS NOTES  : This function has 2 parameters:

                 *tpu    	- This is a pointer to the TPU3 module to use. It is of
                           	type TPU3_tag which is defined in m_tpu3.h

                 channel 	- This is the channel number of the master COMM
                          	channel.


RETURNS NOTES : none

*******************************************************************************/

INT16	 tpu_comm_get_state_no (struct TPU3_tag *tpu, UINT8 channel)
{
	INT16 state_no;
	state_no = (tpu->PARM.R[channel][COMM_STATE_NO]) & 0x00ff;
	return(state_no);	
}

/*******************************************************************************
FUNCTION      : tpu_comm_start_update
PURPOSE       : This function issues an HSR to the COMM master channel to start
		the periodic update matches.
INPUTS NOTES  : This function has 2 parameters:

                 *tpu    	- This is a pointer to the TPU3 module to use. It is of
                           	type TPU3_tag which is defined in m_tpu3.h

                 channel 	- This is the channel number of the master COMM
                          	channel.


RETURNS NOTES : none

*******************************************************************************/

void tpu_comm_start_update (struct TPU3_tag *tpu, UINT8 channel)
{
	/* issue HSR %11 to start periodic state update matches*/	

	tpu_hsr(tpu, channel, COMM_START_UPDATE);
}



/*********************************************************************
 *
 * Copyright:
 *	MOTOROLA, INC. All Rights Reserved.  
 *  You are hereby granted a copyright license to use, modify, and
 *  distribute the SOFTWARE so long as this entire notice is
 *  retained without alteration in any modified and/or redistributed
 *  versions, and that such modified versions are clearly identified
 *  as such. No licenses are granted by implication, estoppel or
 *  otherwise under any patents or trademarks of Motorola, Inc. This 
 *  software is provided on an "AS IS" basis and without warranty.
 *
 *  To the maximum extent permitted by applicable law, MOTOROLA 
 *  DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED, INCLUDING 
 *  IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
 *  PURPOSE AND ANY WARRANTY AGAINST INFRINGEMENT WITH REGARD TO THE 
 *  SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF) AND ANY 
 *  ACCOMPANYING WRITTEN MATERIALS.
 * 
 *  To the maximum extent permitted by applicable law, IN NO EVENT
 *  SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING 
 *  WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS 
 *  INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY
 *  LOSS) ARISING OF THE USE OR INABILITY TO USE THE SOFTWARE.   
 * 
 *  Motorola assumes no responsibility for the maintenance and support
 *  of this software
 ********************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -