Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-8452 Slave continuously waiting for event - I2C

Hello,

 

Recently I have been working on a I2C Slave simulation for one of my Master circuits, using the NI-8452 Interface. I have created a GUI in the Visual Studio 6 C++ and I am capable of setting up the Slave, waiting for an event from the Master and writing the data to it following the data request event. However, I have a problem with getting the procedure to run continuously - every time after sending the data I would like the Slave to be waiting for an event once again. I've tried using several 'for' and 'while' loops but I seem to be getting some synchronization problems with my Master - commands end in errors and crashes.

 

I guess my questions is about any potential examples available, demonstrating a continuous wait for a request from the Master, replying to that request and then going back to the waiting state.

 

Best regards,

 

Konrad

0 Kudos
Message 1 of 3
(5,082 Views)

Hi Konrad, 

 

You can find a number of Master/Slave examples in the NI Example Finder: https://forums.ni.com/t5/Example-Programs/ct-p/code-documents but the main Master/Slave Architecture is shown in the following example: https://forums.ni.com/t5/Example-Code/Master-Slave-Architecture-Using-Notifiers-With-Two-Slave-Loops...

 

I have also included an example of a Master/Slave Layout using Events that you can follow the logic through on, and see if that helps implement the theory in your own design. 

Hope these are of help! Let us know how you get on. 

 

Rebecca

 

 

0 Kudos
Message 2 of 3
(5,046 Views)

Hello Rebecca,

 

Thank you for your swift reply. As I said, so far I have been using Microsoft Visual Studio C++ in order to operate my 8452 and since I do not have LabView I cannot open and look into any examples you have listed.

 

In my system the Master is continuously reading data from all of the Slaves on the I2C bus, the reading interval is 100ms (although it can be changed). I am struggling to keep the 8452 active as a Slave and to simply send the data to the Master when asked to do so, without system crashing and causing some unexpected behaviour.

 

I was thinking about using Clock Stretching, so that the Master has to wait before sending another request. Does the API currently support such function for the 8542?

 

Many thanks,

 

Konrad

0 Kudos
Message 3 of 3
(5,014 Views)