Application Note: TMC429 & TMC24x Getting Started (V. 1.0 / 2012-FEB-10) 4
Copyright © 2012 TRINAMIC Motion Control GmbH & Co. KG
4 Initialization of the TMC429
On first sight, the sample C code included within the ZIP archive 'tmc429demo.zip' might give the
impression that the initialization of the TMC429 is a complicated task due to a couple of different
routines used. The intent of this sample C code and its different routines is to demonstrate how to
access the registers of the TMC429. All together, these routines just perform a sequence of SPI
datagramms that perform the initialization of the TMC429. So, for those who are familiar with the
TMC429 and its SPI datagramms, the program structure might become more compact and the
initialization code might look like
for (i=0; i<(128-2); i+=2) // initialize TMC429 RAM table (SPI conf. & quarter sine wave LUT)
{
spo = 0x80000000 | (i<<(25-1)) | (tmc429_ram_tab[i+1]<<8) | (tmc429_ram_tab[i]); // RRS=1, RW=0
spi = tmc429spi( spo );
}
spi = tmc429spi(0x7E010701); // initialize stepper motor global parameter register, LSMD=1 for EvalKit
spi = tmc429spi(0x........); // initialize . . .
where tmc429_ram_tab[] is an array representing the content of the TMC429 configuration RAM (see
section 0) and tmc429spi(long int spo) represents a routine that sends a 32 bit wide SPI datagram to
the TMC429 and receives a 32 bit wide SPI datagram from the TMC429. The TMC429 needs to be
initialized after each power on. A micro controller is suitable to do the initialization of the TMC429 by
just sending a sequence of SPI datagramms to the TMC429 after power on. The TMC429 itself
performs a power on reset (POR). Almost any register of the TMC429 is set to zero by the POR. The
RAM of the TMC429 is not initialized by the power on reset, and so the RAM has a more or less
random content after power on. In contrast to power on, there is no need for re-initialization of the
TMC429 after it has been set into power-down by writing the power_down (JDX=%1000) register. The
initialization of the TMC429 enfolds three main phases:
1. initializing the TMC429 configuration RAM
2. configuring the stepper motor global parameter register
3. parameterizing individual stepper motor registers
• choose micro step resolution / step pulse pre-divider / acceleration pre-divider
• choose step velocities v_min and v_max and the step acceleration a_max
• calculate pmul & pdiv for the chosen set of parameters
• set the reference switch configuration and the ramp mode
• set the automatic current scaling [optional]
4.1 TMC429 Configuration RAM for TMC236/TMC239/TMC246/TMC249
First of all, the stepper motor driver datagram configuration has to be written into the RAM area of
the TMC428. Additionally, the micro step look-up table (LUT) has to be initialized when using micro
stepping. Both tables should be put into one single array for initialization of the TMC428 by the micro
controller after power up. The following constant array represents the configuration concerning
stepper motor driver chain and sine wave look up table according to the example given within the
TMC428 datasheet (sections "Stepper Motor Driver Datagram Configuration" and "Initialization of the
Microstep Look-Up-Table"):
unsigned char tmc429_ram_tab[128]=
{
0x10, 0x05, 0x04, 0x03, 0x02, 0x06, 0x10, 0x0D, 0x0C, 0x0B, 0x0A, 0x2E, 0x11, 0x05, 0x04, 0x03,
0x02, 0x06, 0x11, 0x0D, 0x0C, 0x0B, 0x0A, 0x2E, 0x07, 0x05, 0x04, 0x03, 0x02, 0x06, 0x0f, 0x0D,
0x0C, 0x0B, 0x0A, 0x2E, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
0x00, 0x02, 0x03, 0x05, 0x06, 0x08, 0x09, 0x0B, 0x0C, 0x0E, 0x10, 0x11, 0x13, 0x14, 0x16, 0x17,
0x18, 0x1A, 0x1B, 0x1D, 0x1E, 0x20, 0x21, 0x22, 0x24, 0x25, 0x26, 0x27, 0x29, 0x2A, 0x2B, 0x2C,
0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x38, 0x39, 0x3A, 0x3B,
0x3B, 0x3C, 0x3C, 0x3D, 0x3D, 0x3E, 0x3E, 0x3E, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F
};