02.06.2013 Views

TMC428 – Application Note - Trinamic

TMC428 – Application Note - Trinamic

TMC428 – Application Note - Trinamic

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>TMC428</strong> <strong>–</strong> <strong>Application</strong> <strong>Note</strong> <strong>–</strong> <strong>TMC428</strong> Getting Started <strong>–</strong> Including StallGuard TM 11<br />

(v. 2.00 / April 14, 2008)<br />

3.1 How to Get the Driver Chain Status Information <strong>–</strong> Code Example<br />

The following C code example (part of tmc428demo.zip) outlines how to get the raw status bits from a<br />

SPI stepper motor driver chain into the <strong>TMC428</strong> registers datagram_high_word and<br />

datagram_low_word.<br />

void tmc428_get_datagram_words( long int *datagram_low_word, long int *datagram_high_word )<br />

{<br />

long int spi, spo;<br />

}<br />

// write datagram_low_word (or high_word) for initialization, sets CDGW to '1'<br />

spi = spi428glue( 0, 0x3, JDX_DATAGRAMM_LOW, WRITE, 0);<br />

spo = tmc428spi( spi );<br />

// wait until CDGW becomes '0'<br />

do<br />

{<br />

Sleep(1); // (wait 1ms, allows the operating system to focus on other tasks)<br />

spi = spi428glue( 0, 0x3, JDX_DATAGRAMM_LOW, READ, 0);<br />

spo = tmc428spi( spi );<br />

} while (!(0x40000000 & (~spo))); // mask CDGW<br />

spi = spi428glue( 0, 0x3, JDX_DATAGRAMM_LOW, READ, 0);<br />

spo = tmc428spi( spi );<br />

*datagram_low_word = 0x00FFFFFF & spo;<br />

spi = spi428glue( 0, 0x3, JDX_DATAGRAMM_HIGH, READ, 0);<br />

spo = tmc428spi( spi );<br />

*datagram_high_word = 0x00FFFFFF & spo;<br />

Copyright © 2005-2008 TRINAMIC Motion Control GmbH & Co. KG

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!