Here is my simple question.How can I send 12 bits data from pic18f to a stepper motor controller (tmc 239)?? This is problem for me, because i know one register has only 8 bits, that means i can only send one byte of data.
Here is my simple question.How can I send 12 bits data from pic18f to a stepper motor controller (tmc 239)?? This is problem for me, because i know one register has only 8 bits, that means i can only send one byte of data.
TMC239 uses analog inputs or SPI to communicate with microcontrollers. Have a closer look into TMC239 and PIC18F datasheets, and you will see how to do it.
Hi,
I'd advise you creating two buffer registers. Then use the first one to save one byte (8 bits) and the second one can be used to save the 4 useful bits left.
In your code implementation you'll simply ignore the two bits in the second buffer.
Everything you need can be implemented with software.
Then use, as namqn said, the SPI modules of the PIC18F and your TCM239 for communication between the PIC and the driver.
I don't think, that you read the TMC239 datasheet thorougly. It also says this:
Even when there is only one device attached to a CPU, the CPU can communicate with it using a 16 bit transmission. In this case, the upper 4 bits are dummy bits.
This is actually required, cause SPI, by original defintion, is transmitting multiples of 8 bit. So the problem is, how to transmit 16 bit with a 8 bit SPI interface. I'm pretty sure that you are able to solve this problem, there are plenty of SPI examples using larger entities than 1 byte.