Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] SPI communication problem

Status
Not open for further replies.

H2M

Member level 1
Joined
Aug 11, 2016
Messages
36
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,624
Hi
I want to read data from 16 bits DRV8711 stepper motor driver with an Atmega16 microcontroller by using SPI protocol.
The DRV8711 module have a 16-bit serial write, with a read/write bit, 3 address bits and 12 data bits.
I can correctly write any data to goal register but i cant read from register.
When i want to read data register i have get a 12 bits from DRV8711. how can i get this bits with Atmega16(it is a 8 bits shift register)?
someone help me.
Thanks.
 

Section 7.5.1 of the data sheet shows how to use two 8-bit exchanges to achieve a 16-bit exchange.
Don't forget that every SPI operation is an exchange. Therefore you need to start by writing a value to the SPI master that will contain the correct bits to request a read, , pick up the value just received, perform a 2nd exchange where you send anything (probably 0x00) and then merge the two received values together to get the 12-bit value.
You will need to select the SPI slave yourself before doing the above and then deselect it afterwards. (At least that is how I read the last paragraph of Page 135 of the Atmega16 data sheet.)
Susan
 

Hi Aussie
I can read correctly DRV8711 registers but i cant correctly merge the two received values. I think the problem are the reserved bits. when i read a register contain reserved bits, what values is the reserved bits? zero? empty?...
 

what values is the reserved bits? zero? empty?...
Why do you care for at all? Just mask them out.

Code:
read_val = (read_h & 0xf) <<8 | read_l;
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top