| 
	
	|  |  |  
	
		| View previous topic :: View next topic |  
		| Author | Message |  
		| Will Reeve Guest
 
 
 
 
 
 
 
			
			
			
			
			
			
			
			
			
 
 | 
			
				| I2C in slace mode doesn't seem to set SSPCON correctly? |  
				|  Posted: Thu May 29, 2003 3:07 am |   |  
				| 
 |  
				| No matter how I try I can’t get I2C to work properly with the CCS #use 
 I want:
 #use i2c(Slave,sda=PIN_C4,scl=PIN_C3,force_hw,address=0x1F)
 
 This line sets the address correctly, but leaves SSPCON = 0x00, when I want it to be 0x36 (which sets slave mode)
 
 If I manually do
 #byte SSPCON = 0x14
 SSPCON = 0x36
 
 all works well!!!!! But I don’t believe I should have to do this myself?
 I am using 3.158 and a PIC16F873.
 
 Any ideas?
 
 Will
 ___________________________
 This message was ported from CCS's old forum
 Original Post ID: 144514836
 |  |  
		|  |  
		| PCM programmer 
 
 
 Joined: 06 Sep 2003
 Posts: 21708
 
 
 
			    
 
 | 
			
				| Re: I2C in slace mode doesn't seem to set SSPCON correctly? |  
				|  Posted: Thu May 29, 2003 10:42 am |   |  
				| 
 |  
				| :=This line sets the address correctly, but leaves SSPCON = 0x00, when I want it to be 0x36 (which sets slave mode) :=I am using 3.158 and a PIC16F873.
 ------------------------------------------------------------
 
 I made the following test program and compiled it with
 PCM vs. 3.158.  It puts 0x36 into register 0x14.
 See the .LST file below:
 
 <PRE>
 #include "c:\Program Files\Picc\Devices\16F873.H"
 #fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
 #use delay(clock = 8000000)
 #use i2c(Slave,sda=PIN_C4,scl=PIN_C3,force_hw,address=0x1F)
 <BR>
 void main(void)
 {
 char c;
 <BR>
 c = i2c_read();
 <BR>
 while(1);
 }
 
 0000                00252 .................... void main(void)
 0004 0184       00253 CLRF   04
 0005 301F       00254 MOVLW  1F
 0006 0583       00255 ANDWF  03,F
 0007 3006       00256 MOVLW  06
 0008 1683       00257 BSF    03.5
 0009 009F       00258 MOVWF  1F
 0016 301F       00259 MOVLW  1F
 0017 0093       00260 MOVWF  13
 
 // Right here, it's moving 0x36 into register 0x14
 0018 3036       00261 MOVLW  36
 0019 1283       00262 BCF    03.5
 001A 0094       00263 MOVWF  14
 0000                00264 .................... {
 0000                00265 .................... char c;
 0000                00266 ....................
 0000                00267 .................... c = i2c_read();
 001B 1683       00268 BSF    03.5
 001C 1814       00269 BTFSC  14.0
 001D 2820       00270 GOTO   020
 001E 1283       00271 BCF    03.5
 001F 281B       00272 GOTO   01B
 0020 1283       00273 BCF    03.5
 0021 0813       00274 MOVF   13,W
 0022 00A6       00275 MOVWF  26
 0000                00276 ....................
 0000                00277 ....................
 0000                00278 .................... while(1);
 0023 2823       00279 GOTO   023
 0000                00280 .................... }
 </PRE>
 
 ___________________________
 This message was ported from CCS's old forum
 Original Post ID: 144514853
 |  |  
		|  |  
		| Will Reeve Guest
 
 
 
 
 
 
 
			
			
			
			
			
			
			
			
			
 
 | 
			
				| Re: I2C in slace mode doesn't seem to set SSPCON correctly? |  
				|  Posted: Mon Jun 02, 2003 3:55 am |   |  
				| 
 |  
				| Hi, Indeed my compiled code seems to do the same! Somewhere after that it is set to 0x00 as I have to manual set it to 0x36 in my init_hardware procedure and all works from then on! I will investigate. Thanks for you help.
 
 Will
 ___________________________
 This message was ported from CCS's old forum
 Original Post ID: 144514946
 |  |  
		|  |  
		| PCM programmer 
 
 
 Joined: 06 Sep 2003
 Posts: 21708
 
 
 
			    
 
 | 
			
				| Re: I2C in slace mode doesn't seem to set SSPCON correctly? |  
				|  Posted: Mon Jun 02, 2003 12:33 pm |   |  
				| 
 |  
				| :=Hi, :=Indeed my compiled code seems to do the same! Somewhere after that it is set to 0x00 as I have to manual set it to 0x36 in my init_hardware procedure and all works from then on! I will investigate. Thanks for you help.
 ---------------------------------------------------------
 
 Look for a "setup_spi()" statement.  This CCS function does
 write to SSPCON.
 ___________________________
 This message was ported from CCS's old forum
 Original Post ID: 144514970
 |  |  
		|  |  
		|  |  
  
	| 
 
 | 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
 
 |