Thank you very much for the answer.
I switched to using the TWI library, as you recommended.
Regarding you code example wrote above, I don't understand this part:
Code: Select all
reg_data = TWI_Read(0u); // No acknowledge (read only one byte)
That is, it reads only one bit of its 8 can the value of the 8-bit address be read and in this case could i replace "0u" with the value of the subaddress ? Or I will have to send the status of each bit in the address according to the example posted by me below!
For example, or rather, to continue your example, I accessed the subaddress called "INPUT MULTIPLEXER & AUX OUT" with the method from the datasheet "No incremental bus". According to the TDA datasheet, this subaddress can take the following 4 values corresponding to the selection of entries 1 ... 4. I have represented these values in the image below where I understood that D3 ... D6 can take any value between 0 and 1, the same as D7 (I chose 0). So, I think (but I'm not sure) that I'm going to have to consider only the first three bits. On the right side of the image, in separate columns, I made the necessary conversion so that I could represent all 8 bits as an address.
- Input Multiplexer subadress values for INT1-4.jpg (46.87 KiB) Viewed 2893 times
So, the first question is if in the case of selecting an INTPUTs it is enough to rewrite the subaddress with one of the four values in the attached image? And if so, what are the steps I can take to do that? For example, I could use the following code inspired by your example but I don't know if it's written correctly !!!
Code: Select all
TWI_Start(); // issue TWI start signal
TWI_Write(0x80); // slave address (with ADDR = 0) + Write bit
TWI_Write(0x09); // INPUT MULTIPLEXER & AUX OUT
// Now I send bits corresponding to INTPUT 1 selection.I don't know if it's correct !!!
TWI_Write(1); // bit D0 = 0
TWI_Write(2); // bit D1 = 1
TWI_Write(3); // bit D2 = 1
TWI_Stop();