I am a glutton for punishment. I understand that the 18M2 and others that have I2C capability are not inherently multimaster capable.
I have a use for many seperate uPs to announce a change in their status to a central computer. I have found a bridge for I2C to RS232 which is an I2C slave only. Thus poling is not an option and I wouldn't want to waste resources for low trafic poling anyway.
My problem is how to monitor the I2C bus for traffic while still performing background tasks of checking the status of inputs.
I am concerned about the resolution needed for watching the bus for start stop conditions and possibly missing a change of state while off checking on the input states and vice versa. Are the signals stable long enough for the basic interpreter to catch them reliably in multi threaded operation?
I am considering a few options but would appreciate any suggestions and critiques.
1 Use one thread of an 18M2 to monitor the bus while another is checking the inputs and formating the data. Then using HI2C functions to comunicate with the computer. My question here is whether one thread could resolve (in bit bang mode??) the traffic generated by another chip using HI2C functions. There is still the off chance of two chips starting at the same time which would need attention not supplied by the HI2C functions.
2. A more implicit resolution might be to (slightly) modify the pullup voltage on the CLK line when you are taking control (using another output to pull down through a 100K?? ohm resistor)and using ADC on another pin to determine that, if the voltage is lower than normal, another chip is in control. This could also detect simultaneous attempts in that 2 chips pulling down together would drop the voltage by two incriments. Of course something like this could be done with a third wire but keeping it to two would be more elegant.
I have seen the post about how to break up If's etc in multi-threading, I am also wondering how commands such as the ADC measurements affect timing and therefor resolution.
Any words of wisdom before I start my adventure?
I have a use for many seperate uPs to announce a change in their status to a central computer. I have found a bridge for I2C to RS232 which is an I2C slave only. Thus poling is not an option and I wouldn't want to waste resources for low trafic poling anyway.
My problem is how to monitor the I2C bus for traffic while still performing background tasks of checking the status of inputs.
I am concerned about the resolution needed for watching the bus for start stop conditions and possibly missing a change of state while off checking on the input states and vice versa. Are the signals stable long enough for the basic interpreter to catch them reliably in multi threaded operation?
I am considering a few options but would appreciate any suggestions and critiques.
1 Use one thread of an 18M2 to monitor the bus while another is checking the inputs and formating the data. Then using HI2C functions to comunicate with the computer. My question here is whether one thread could resolve (in bit bang mode??) the traffic generated by another chip using HI2C functions. There is still the off chance of two chips starting at the same time which would need attention not supplied by the HI2C functions.
2. A more implicit resolution might be to (slightly) modify the pullup voltage on the CLK line when you are taking control (using another output to pull down through a 100K?? ohm resistor)and using ADC on another pin to determine that, if the voltage is lower than normal, another chip is in control. This could also detect simultaneous attempts in that 2 chips pulling down together would drop the voltage by two incriments. Of course something like this could be done with a third wire but keeping it to two would be more elegant.
I have seen the post about how to break up If's etc in multi-threading, I am also wondering how commands such as the ADC measurements affect timing and therefor resolution.
Any words of wisdom before I start my adventure?