  | 
	  | 
		 
	 
	
		| View previous topic :: View next topic   | 
	 
	
	
		| Author | 
		Message | 
	 
	
		
			Renato and Davide Guest
 
 
 
 
  
			
			
			
			
			
			
			
			
			
			
  
		  | 
		
			
				| PIC 16F877. Implementation of i2c master with interrupt. | 
			 
			
				 Posted: Wed Nov 28, 2001 9:48 am     | 
				     | 
			 
			
				
  | 
			 
			
				Hello at everybody,
 
we have wrote this code:
 
 
#USE I2C(master, sda=PIN_C4, scl=PIN_C3, SLOW, NOFORCE_SW)
 
 
int i=0;
 
 
void main ()
 
{
 
 i2c_start ();
 
}
 
 
#INT_SSP
 
void master()
 
{
 
 i2c_write (buffer[i]); //buffer[0] = 0x0E (slave address)
 
 if (i==21) i2c_stop ();
 
 i++;
 
}
 
 
 
* The problem is that the instruction i2c_start() in main provokes an interrupt, but the i2c_write () doesn't cause interrupt, is it correct ? If it is correct what is the usefullness?
 
 
* We have seen that the i2c_write () returns 0 (ACK) when the slave address is correct, but this not cause new interrupt.
 
 
* We had test that if the instruction i2c_write is located in  main it cause the interrupt:
 
 
void main ()
 
{
 
 i2c_start (); //cause the interrupt
 
 i2c_write (); //cause the interrupt
 
}
 
 
We do not understand the usefullness.
 
 
IDE Version = 2.32
 
PCB Version = 3.043
 
PCM Version = 3.043
 
Thank you for the support. Best regards
 
___________________________
 
This message was ported from CCS's old forum
 
	Original Post ID: 1352 | 
			 
		  | 
	 
	
		  | 
	 
	
		
			Tomi Guest
 
 
 
 
  
			
			
			
			
			
			
			
			
			
			
  
		  | 
		
			
				| Re: PIC 16F877. Implementation of i2c master with interrupt. | 
			 
			
				 Posted: Wed Nov 28, 2001 11:51 am     | 
				     | 
			 
			
				
  | 
			 
			
				Bon giorno,
 
the i2c_write() function includes a wait state after moving the byte into SSPBUF (it waits for the end of the write cycle).
 
Try this instead of "i2c_write(buffer[i])" line:
 
 
bit_set(*0x14,4); // optional:the clock polarity instruction if it is necessary
 
*0x13 = buffer[i]; // direct write into SSPBUF
 
 
:=Hello at everybody,
 
:=we have wrote this code:
 
:=
 
:=#USE I2C(master, sda=PIN_C4, scl=PIN_C3, SLOW, NOFORCE_SW)
 
:=
 
:=int i=0;
 
:=
 
:=void main ()
 
:={
 
:= i2c_start ();
 
:=}
 
:=
 
:=#INT_SSP
 
:=void master()
 
:={
 
:= i2c_write (buffer[i]); //buffer[0] = 0x0E (slave address)
 
:= if (i==21) i2c_stop ();
 
:= i++;
 
:=}
 
:= 
 
:=* The problem is that the instruction i2c_start() in main provokes an interrupt, but the i2c_write () doesn't cause interrupt, is it correct ? If it is correct what is the usefullness?
 
:=
 
:=* We have seen that the i2c_write () returns 0 (ACK) when the slave address is correct, but this not cause new interrupt.
 
:=
 
:=* We had test that if the instruction i2c_write is located in  main it cause the interrupt:
 
:=
 
:=void main ()
 
:={
 
:= i2c_start (); //cause the interrupt
 
:= i2c_write (); //cause the interrupt
 
:=}
 
:=
 
:=We do not understand the usefullness.
 
:=
 
:=IDE Version = 2.32
 
:=PCB Version = 3.043
 
:=PCM Version = 3.043
 
:=Thank you for the support. Best regards
 
___________________________
 
This message was ported from CCS's old forum
 
	Original Post ID: 1356 | 
			 
		  | 
	 
	
		  | 
	 
	
		 | 
	 
 
  
	 
	    
	   | 
	
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
  | 
   
 
  
Powered by phpBB © 2001, 2005 phpBB Group
  
		 |