Netduino home hardware projects downloads community

Jump to content


Photo

SPI read/write with registers


  • Please log in to reply
No replies to this topic

#1 nlsa

nlsa

    Member

  • Members
  • PipPip
  • 11 posts

Posted 25 March 2016 - 11:52 PM

Dear friends,

 

I am trying to communicate with a TI AMC7834 controller chip via SPI, using a NP2 with ver 4.3.1.0 firmware. 

It's not clear to me what sequence of commands the Netduino implementation of SPOT.SPI actually needs. Being a rookie with SPI, I have searched for example code online but I'm still confused.

 

Is the following sufficient for setting a register?

 

            byte[] WriteBuf = new byte[] { (byte)Register_ID, 0x10 };  // writes 0x10 to RegisterID
            MySPI.Write(WriteBuf);

 

Do I need to manipulate the CS pin myself or is this built it?  

 

Is this sufficient for reading two bytes from a register?

 

            byte[] tx_data = new byte[2];
            byte[] rx_data = new byte[2];
            tx_data[0] = (byte)Register_ID;
            tx_data[1] = 0x00 ;                                // Unsure whether this is needed
            MySPI.WriteRead(tx_data, rx_data);    // read two bytes of data into rx_data           

 

Could someone please point me to an example of reading and writing to a device with registers?

 

Thank you -






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.