| 
	
	|  |  |  
	
		| View previous topic :: View next topic |  
		| Author | Message |  
		| Thomas Guest
 
 
 
 
 
 
 
			
			
			
			
			
			
			
			
			
 
 | 
			
				| Output_high() function |  
				|  Posted: Sun Dec 22, 2002 2:22 pm |   |  
				| 
 |  
				| Hi everyone, 
 I have a variable which contain the address of a port, but I want to use this variable for the Output_high() function.  The Output_High() function, as you know, requires a constant in its argument.  How do I "convert" the content of a variable to a constant so I can use in the Output_High() function.
 
 test = BIT_A3;
 Output_High(test);   //?
 
 Thank you in advance
 
 
 ___________________________
 This message was ported from CCS's old forum
 Original Post ID: 10202
 |  |  
		|  |  
		| Dale Herman Guest
 
 
 
 
 
 
 
			
			
			
			
			
			
			
			
			
 
 | 
			
				| Re: Output_high() function |  
				|  Posted: Sun Dec 22, 2002 4:47 pm |   |  
				| 
 |  
				| cant <a href="http://www.ccsinfo.com/faq/?26" TARGET="_blank">http://www.ccsinfo.com/faq/?26</a>
 ___________________________
 This message was ported from CCS's old forum
 Original Post ID: 10203
 |  |  
		|  |  
		| Tomi Guest
 
 
 
 
 
 
 
			
			
			
			
			
			
			
			
			
 
 | 
			
				| Re: Output_high() function |  
				|  Posted: Mon Dec 23, 2002 2:34 am |   |  
				| 
 |  
				| If you use FIXED_IO or any other way to be sure that the port pin is in output state then you can use the following: 
 void My_Output_High(char bitaddress)
 {
 char byteaddr,bitaddr;
 
 byteaddr = bitaddress >> 3;
 bitaddr = bitaddress & 0x07;
 bit_set(*byteaddr,bitaddr);
 }
 
 If you use 16F87X then it is possible to use:
 
 void My_Output_High(char bitaddress)
 {
 char byteaddr,bitaddr;
 
 byteaddr = bitaddress >> 3;
 bitaddr = bitaddress & 0x07;
 bit_clear(*(byteaddr | 0x80),bitaddr); // set pin to output
 bit_set(*byteaddr,bitaddr);
 }
 
 And of course you can use the same way for 18Fxx2 to compute the right TRIS register address.
 
 
 :=Hi everyone,
 :=
 :=I have a variable which contain the address of a port, but I want to use this variable for the Output_high() function.  The Output_High() function, as you know, requires a constant in its argument.  How do I "convert" the content of a variable to a constant so I can use in the Output_High() function.
 :=
 :=test = BIT_A3;
 :=Output_High(test);   //?
 :=
 :=Thank you in advance
 :=
 :=
 ___________________________
 This message was ported from CCS's old forum
 Original Post ID: 10212
 |  |  
		|  |  
		| Bruce R. Knox Guest
 
 
 
 
 
 
 
			
			
			
			
			
			
			
			
			
 
 | 
			
				| Re: Output_high() function |  
				|  Posted: Mon Dec 23, 2002 7:37 am |   |  
				| 
 |  
				| :=Hi everyone, :=
 :=I have a variable which contain the address of a port, but I want to use this variable for the Output_high() function.  The Output_High() function, as you know, requires a constant in its argument.  How do I "convert" the content of a variable to a constant so I can use in the Output_High() function.
 :=
 :=test = BIT_A3;
 :=Output_High(test);   //?
 :=
 :=Thank you in advance
 :=
 :=
 
 Assuming you mean that your variable contains the address of a BIT on a port, why not use bit_set(addr,bit)?
 
 For example:
 
 #byte PORTA = 5
 int test;
 
 test = 3; // Bit 3 position
 bit_set(PORTA,test); // as in the CCS manual!
 
 Of course, you'll have to have set up the TRIS register(s) on your own to use this method.
 
 Bruce
 ___________________________
 This message was ported from CCS's old forum
 Original Post ID: 10214
 |  |  
		|  |  
		|  |  
  
	| 
 
 | 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
 
 |