AN2364 Freescale Semiconductor / Motorola, AN2364 Datasheet - Page 39

no-image

AN2364

Manufacturer Part Number
AN2364
Description
Using the Table Stepper Motor TPU Function (TSM) with the MPC500 Family
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
tpu_tsm_ex1.c
#include "mpc500.c"
#include "mpc500_util.h"
#include "tpu_tsm.h"
/* Prototypes for functions of example program */
void Ext_Isr(void);
void tpu_tsm_int_config(struct TPU3_tag *tpu, UINT8 channel, UINT8 level);
UINT32 tpu_tsm_sip_int_lvl(int int_level);
/* Initialization parameters -- redefine these parameters for a
/*
UINT8 mas_channel = 13;
UINT8 int_level = 2;
UINT8 num_channel = 4;
UINT8 table_size = 24;
INT16 start_position = 0x0010; /* Initial value for desired_ & current_position */
UINT16 table_siz_index = 0x1C00; /* Initial value for table size(1C) and index(00) */
UINT8
void main ()
{
/* An example of a parameter table is shown below. Change this table */
/* to meet your requirements. Duplicate this table with another
/* name for a second TSM function (third, etc.), if different.
static UINT16 table[] = {0xF7FF, 0xE7F0, 0xD7E0, 0xC7D0,
/* Hardware Setup -- machine settings (watchdog, timers, speed, etc.) */
39
UINT16 dp_val; /* Value of desired position for program control. */
UINT16 cp_val; /* Value of current position for program control. */
struct TPU3_tag *tpua = &TPU_A;
int x;
setup_mpc500(40);
flag = 0;
/* Just an integer to hold a value
/* Configuration routines for MPC555 EVB, will need */
/* to be changed if other hardware is used.
/* TPU TSM functions */
/* master channel designation, changes once here. */
/* Set global interrupt level here.
/* Number of channels.
/* Number of bytes/2 in the parameter table.
0xB7C0, 0xA7B0, 0x97A0, 0x8790,
0x7780, 0x6770, 0x5760, 0x4750,
0x3740, 0x2730, 0x1720, 0x0F10,
0x0E0F, 0x0C0D, 0x0A0B, 0x0809,
0x0607, 0x0405, 0x0203, 0x0001};
Freescale Semiconductor, Inc.
Using the Table Stepper Motor TPU Function
/* Interrupt test flag.
For More Information On This Product,
/* Utility routines for using MPC500 devices
/*Setup device and programm PLL to 40MHz*/
second parallel TSM initialization.
Go to: www.freescale.com
/* pointer for TPU routines */
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
MOTOROLA

Related parts for AN2364