| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| alexz 
 
 
 Joined: 17 Sep 2004
 Posts: 133
 Location: UK
 
 
			    
 
 | 
			
				| simple macro problem |  
				|  Posted: Fri Oct 15, 2004 10:03 am |   |  
				| 
 |  
				| #define	USBN_RST    USBN_BUS = 5 
 void main(void)
 {
 USBN_RST;  <---Error:  A numeric expression must appear here
 }
 _________________
 Alex
 |  | 
	
		|  | 
	
		| dvsoft 
 
 
 Joined: 28 Nov 2003
 Posts: 46
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri Oct 15, 2004 10:37 am |   |  
				| 
 |  
				| bonsoir 
 juste write
 #define USBN_RST USBN_BUS  5
 
 when you use USBN_RST USBN_BUS in expression the compiler replace by 5
 
 Alain
 |  | 
	
		|  | 
	
		| Mark 
 
 
 Joined: 07 Sep 2003
 Posts: 2838
 Location: Atlanta, GA
 
 
			      
 
 | 
			
				|  |  
				|  Posted: Fri Oct 15, 2004 11:06 am |   |  
				| 
 |  
				| Did you declare USBN_BUS? |  | 
	
		|  | 
	
		| alexz 
 
 
 Joined: 17 Sep 2004
 Posts: 133
 Location: UK
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Mon Oct 18, 2004 4:00 am |   |  
				| 
 |  
				|  	  | Mark wrote: |  	  | Did you declare USBN_BUS? | 
 
 #define		USBN_BUS		PORTC;
 _________________
 Alex
 |  | 
	
		|  | 
	
		| Mark 
 
 
 Joined: 07 Sep 2003
 Posts: 2838
 Location: Atlanta, GA
 
 
			      
 
 | 
			
				|  |  
				|  Posted: Mon Oct 18, 2004 6:40 am |   |  
				| 
 |  
				| Okay, did you declare PORTC? 
 
  	  | Code: |  	  | CCS PCM C Compiler, Version 3.206, 22485               18-Oct-04 08:40 
 Filename: test.LST
 
 ROM used: 17 words (0%)
 Largest free fragment is 2048
 RAM used: 5 (3%) at main() level
 5 (3%) worst case
 Stack:    0 locations
 
 *
 0000:  MOVLW  00
 0001:  MOVWF  0A
 0002:  GOTO   004
 0003:  NOP
 ....................  #include <16F877.H>
 ....................  //////// Standard Header file for the PIC16F877 device ////////////////
 .................... #device PIC16F877
 .................... #list
 ....................
 .................... #fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
 .................... #use delay(clock = 4000000)
 ....................
 .................... #byte PORTC = 0x07
 .................... #define USBN_BUS PORTC
 .................... #define USBN_RST USBN_BUS = 5
 .................... void main()
 .................... {
 0004:  CLRF   04
 0005:  MOVLW  1F
 0006:  ANDWF  03,F
 0007:  BSF    03.5
 0008:  BSF    1F.0
 0009:  BSF    1F.1
 000A:  BSF    1F.2
 000B:  BCF    1F.3
 ....................
 .................... USBN_RST;
 000C:  MOVLW  05
 000D:  BCF    03.5
 000E:  MOVWF  07
 .................... while(TRUE)
 ....................  {
 ....................  }
 000F:  GOTO   00F
 .................... }
 ....................
 0010:  SLEEP
 
 Configuration Fuses:
 Word  1: 3F71   XT NOWDT PUT NOPROTECT BROWNOUT NOLVP NOCPD NOWRT NODEBUG
 
 | 
 |  | 
	
		|  | 
	
		| alexz 
 
 
 Joined: 17 Sep 2004
 Posts: 133
 Location: UK
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Mon Oct 18, 2004 6:42 am |   |  
				| 
 |  
				| Yes, it is declared in the header file, I ve checked that _________________
 Alex
 |  | 
	
		|  | 
	
		| Mark 
 
 
 Joined: 07 Sep 2003
 Posts: 2838
 Location: Atlanta, GA
 
 
			      
 
 | 
			
				|  |  
				|  Posted: Mon Oct 18, 2004 6:46 am |   |  
				| 
 |  
				| Well as everyone can clearly see, it works per my sample posted so you must be giving out misinformation.  post a small simple but complete program that demonstrates the problem and maybe we can tell you what is wrong. |  | 
	
		|  | 
	
		| alexz 
 
 
 Joined: 17 Sep 2004
 Posts: 133
 Location: UK
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Mon Oct 18, 2004 6:59 am |   |  
				| 
 |  
				| It is working now, that is the way I ve eventually done it:
 
 #include "SFR.h"
 #define		USBN_BUS		    PORTC
 #define		USBN_MCNTRL_ADDR	    0x05
 #define		NUMBER	                     3
 
 #define		USBN_RST 	PORTC = N_MCNTRL_ADDR;\
 bit_set(PORTC,NUMBER)
 
 void main(void)
 {
 USBN_RST;
 }
 
 Thank you very much for your help !
 _________________
 Alex
 |  | 
	
		|  | 
	
		|  |