| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| robotam 
 
 
 Joined: 13 Nov 2007
 Posts: 15
 
 
 
			    
 
 | 
			
				| i2C_Stream |  
				|  Posted: Wed Feb 13, 2008 3:36 pm |   |  
				| 
 |  
				| Hello 
 Someone could post a example code of i2c communication using "Stream".
 
 thanks
 |  | 
	
		|  | 
	
		| rnielsen 
 
 
 Joined: 23 Sep 2003
 Posts: 852
 Location: Utah
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu Feb 14, 2008 9:52 am |   |  
				| 
 |  
				| As far as I know, STREAM is only available with the RS232, not the I2C. 
 Ronald
 |  | 
	
		|  | 
	
		| PCM programmer 
 
 
 Joined: 06 Sep 2003
 Posts: 21708
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu Feb 14, 2008 11:43 am |   |  
				| 
 |  
				| Streams can be specified in the #use i2c() statement in vs. 4 of the compiler.  See the current manual:
 http://www.ccsinfo.com/downloads/CReferenceManual.pdf
 
 
 To answer the question, specify the name of the stream in the #use i2c()
 statement.    Do this in the same way as a stream is specified in a
 #use rs232() statement.    Then, in every i2c function, specify the stream
 that you're using.
 
 Instead of doing this:
 
 You would do  this:
 
  	  | Quote: |  	  | i2c_write (stream, data); | 
 
 All the rest of the i2c functions must also have a stream parameter
 (if you are using streams).  Example:
 
  	  | Code: |  	  | i2c_poll(stream);
 data = i2c_read(stream);
 data = i2c_read(stream, ack);
 i2c_start(stream);
 i2c_start(stream, restart);
 i2c_stop(stream);
 | 
 |  | 
	
		|  | 
	
		|  |