This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C123GH6PM: SPI and I2C communication using board to board and memory related topic

Part Number: TM4C123GH6PM

Hi everyone,

 I am having certain doubts in TIVA C Series TM4c123gh6pm

1. When I am doing board to board communication, I should go with interrupt method or polling method. Which is better and why is it so.
2. When doing board to board in I2C protocol, I designed a function as below.

void I2C1_Write_byte(int slave_address, unsigned char slave_memory_address, unsigned char data);


int I2C1_read_byte(int slave_address, unsigned char slave_memory_address);

when doing board to board, I am clueless what argument to use in place of slave_memory_address. The code works perfectly with a slave but board to board, I don't know. What are the things to be taken care when I am trying to communicate between 2 TIVA C series boards. 

3. Regarding the image I attached. Both read and write register is in same location with the same memory offset. How it is working internally. How the processor comes to know the register I used is read/write register.

Forgive me in advance if there is something trivial I asked about! Anyhow I am curious to know the answers.

Thanks and Regards

  • Hi,

      

    Hi,

      Sorry, I'm currently traveling. I will reply you next Monday. 

  • 1. When I am doing board to board communication, I should go with interrupt method or polling method. Which is better and why is it so.

    Hi,

      That is really up to you and it depends on the complexity of your application. If the sole application is only I2C transmit/receive then polling may be sufficient. Take a look at this example at C:\ti\TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c123gxl-boostxl-senshub\humidity_sht21_simple. This one uses polling. If you have a complicated application with many things going on at the same time, then I will suggest you use interrupt.

    2. When doing board to board in I2C protocol, I designed a function as below.

    void I2C1_Write_byte(int slave_address, unsigned char slave_memory_address, unsigned char data);


    int I2C1_read_byte(int slave_address, unsigned char slave_memory_address);

    when doing board to board, I am clueless what argument to use in place of slave_memory_address. The code works perfectly with a slave but board to board, I don't know. What are the things to be taken care when I am trying to communicate between 2 TIVA C series boards. 

    You need to read your slave device datasheet to know what slave_memory_address to pass. The first argument of your custom function is to identify the address of the slave device to talk to. For example, you may have 10 I2C devices on the I2C bus. The slave_address tells which device to talk to. If the device is a memory device then you need to provide which memory location to access. Let's say you want to write to memory location at 0x100 then you put this value for your slave_memory_address. Again, you need to read your slave device datasheet to know how to read or write to a particular address. 

    . Regarding the image I attached. Both read and write register is in same location with the same memory offset. How it is working internally. How the processor comes to know the register I used is read/write register.

    Both read and write shares the same register. Internally, the address decoder will take the R/W signal into account to know if the processor is writing or reading the register. 

  • "You need to read your slave device datasheet to know what slave_memory_address to pass. "

    sir,

     As I have mentioned, the slave is another TIVA C Series board. So, all the registers are of 32 bit. So I am not getting the idea of How to address this slave memory address? and I'll look into the examples you have said.

    thank you