| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		
			SuperDave
 
 
  Joined: 22 May 2008 Posts: 63 Location: Madison, TN 
			
			 
			 
			
			 
			
			
			
			
			
  
		  | 
		
			
				| Two interrupt problems | 
			 
			
				 Posted: Mon May 07, 2012 9:08 pm     | 
				     | 
			 
			
				
  | 
			 
			
				Two problems  (Version 4.130)
 
First:
 
I have a short nonsense program where this compiles
 
 	  | Code: | 	 		  
 
#INT_timer0   //
 
void EnableLines() {    //
 
  bCActive = rEnC;
 
}
 
 | 	  
 
but this produces the error
 
Error 7 "SpiTest.c" Line 125(9,10): Invalid Pre-Processor directive
 
 	  | Code: | 	 		  
 
#INT_RA   //   ONLY CHANGE IS TIMER0 TO RA
 
void EnableLines() {    //
 
  bCActive = rEnC;
 
}   
 
 | 	  
 
Why the error? How do I get rid of it?
 
 
Second:
 
Port A will actually have three independent pins interrupting on a high to low change. My reading the PICC manual and the 16F1828 manual leave me perplexed. As I see it I have to enable each of them like this
 
Enable_Interrupts (INT_RA1_H2L | INT_RA2_H2L | INT_RA3_H2L); Then within the int routine what's the best way to separate them? Do I have to test the individual bits of the interrupt register? | 
			 
		  | 
	
	
		  | 
	
	
		
			PCM programmer
 
 
  Joined: 06 Sep 2003 Posts: 21708
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Mon May 07, 2012 9:35 pm     | 
				     | 
			 
			
				
  | 
			 
			
				Always post a test program.  I made one and it doesn't fail:
 
 	  | Quote: | 	 		  
 
Build Successful.
 
Loaded C:\Program Files\PICC\Projects\PCM_Test\PCM_TEST.cof.
 
BUILD SUCCEEDED: Mon May 07 20:35:24 2012
 
 
CCS PCM C Compiler, Version 4.130, xxxxx       07-May-12 20:35 | 	  
 
 	  | Code: | 	 		  
 
#include <16F1828.H> 
 
#fuses INTRC_IO, NOWDT 
 
#use delay(clock=4M) 
 
 
int8 bCActive;
 
int8 rEnC;
 
 
#INT_RA    
 
void EnableLines() {     
 
  bCActive = rEnC; 
 
}    
 
 
//==================================
 
void main()
 
{
 
 
 
while(1);
 
} | 	 
  | 
			 
		  | 
	
	
		  | 
	
	
		
			SuperDave
 
 
  Joined: 22 May 2008 Posts: 63 Location: Madison, TN 
			
			 
			 
			
			 
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Tue May 08, 2012 6:26 am     | 
				     | 
			 
			
				
  | 
			 
			
				OK, thanks, late night typo was the problem. My include spec'd a 16F1826, not 1828 the correct part. The 1826 doesn't allow RA.
 
 
So, now the second problem restated. The 16F1828.h file includes these two lines one after the other
 
 	  | Code: | 	 		  
 
#define INT_RA                    0x30FF0B08
 
#define INT_RA0                   0x30010B08
 
 | 	  
 
This compiles
 
 	  | Code: | 	 		  
 
#INT_RA      //port A change interrupt handler
 
void MyTestPgm() (
 
  //stuff
 
}
 
 | 	  
 
This doesn't
 
 	  | Code: | 	 		  
 
#int_RA0   //port A bit0
 
void MyTestPgm() (
 
  //stuff
 
}
 
 | 	  
 
I sort of get it that the two seem to be used differently even though they are in the same section of the include. So I use RA0 in the enable_int and RA to identify the interrupt handler. But if I want multiple bits from Port A, what is the best way to separate them in the handler? Nothing I find seems to deal with that.
 
 
Thanks again,
 
Dave | 
			 
		  | 
	
	
		  | 
	
	
		
			temtronic
 
 
  Joined: 01 Jul 2010 Posts: 9589 Location: Greensville,Ontario 
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Tue May 08, 2012 9:56 am     | 
				     | 
			 
			
				
  | 
			 
			
				Dave, 'somewhere' maybe the onscreen help files ?, CCS shows how to access individual bits of PORTB high nibble (b7..b4).
 
That code does work, I've used it on several projects.
 
hth
 
jay | 
			 
		  | 
	
	
		  | 
	
	
		
			PCM programmer
 
 
  Joined: 06 Sep 2003 Posts: 21708
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		 | 
	
	
		  | 
	
	
		 |