| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| Mrinmoy Dey 
 
 
 Joined: 23 Jan 2018
 Posts: 44
 
 
 
			    
 
 | 
			
				| PIC18F66K40 Interrupt Priority level |  
				|  Posted: Thu Oct 24, 2019 4:37 am |   |  
				| 
 |  
				| Hi All, I am using PIC18F66K40 in one of my projects and my compiler is v5.083. In a part of this project I need to send data through UART when a 1millisecond timer is running; specifically TIMER0. Now I am facing a problem that during the data sending process through UART timer interrupt is on hold. As because both RDA and TIMER are inetrrupt I want to know which one has a higher priority level? As well as is there any process to change the priority level of interrupts??I want timer interrupt to get higher priority than RDA interrupt.
 
 Thank you.
 |  | 
	
		|  | 
	
		| Ttelmah 
 
 
 Joined: 11 Mar 2010
 Posts: 19966
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu Oct 24, 2019 5:01 am |   |  
				| 
 |  
				| Really is a 'read the manual' question: 
 
  	  | Quote: |  	  | #INT_xxxx HIGH - High priority interrupt.  Compiler saves/restores key registers.  This interrupt will interrupt any normal interrupt in progress.
 
 | 
 and in the entry for #device:
 
  	  | Quote: |  	  | HIGH_INTS=TRUE
 Use this option for high/low priority interrupts on the PICĀ® 18.
 
 | 
 
 Basically you need to add the line #DEVICE HIGH_INTS=TRUE up at the
 start of the code (immediately after the processor include is loaded), and
 you can then simply flag an interrupt as 'HIGH' giving it priority over the
 normal interrupts.
 One 'caveat'. Most (all?) PIC18's don't have a priority bit for the INT
 input. If high priority interrupts are enabled, this interrupt is always
 high priority (no choice). So if you are using this interrupt it will have
 the same priority as the 'high priority' ones.
 |  | 
	
		|  | 
	
		| temtronic 
 
 
 Joined: 01 Jul 2010
 Posts: 9588
 Location: Greensville,Ontario
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu Oct 24, 2019 5:13 am |   |  
				| 
 |  
				| I found ,years ago, that if I press F11 while my project is open, that the CCS manual 'magically' pops up !! I use MPLAB BTW, Yeah, I always have it opened as I can't member the syntax to some functions and need a wee bit of help. 
 I'm confused though, you talk about 'sending data' and RDA. To me the PIC is always the 'processor in charge', so sending data would mean the PIC is transmitting data TO another device. RDA is used to receive data FROM a device.
 The good thing is the PIC hardware UARTs have interrupt capabilites for both transmit and receive. Also when doing any serial communications, it's best to use 'buffers'. CCS supplies some example programs, ex_sisr.c , is one of them.
 |  | 
	
		|  | 
	
		| Mrinmoy Dey 
 
 
 Joined: 23 Jan 2018
 Posts: 44
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu Oct 24, 2019 5:36 am |   |  
				| 
 |  
				| @Ttelmah Thank you Sir. Actually I have those lines in my code but turned off those lines as per one of your previous suggestion for this particular controller on PIN_SELECT and I also forgot about that INTS are turned off now. I think it will work now.
 
 Thank you again.
 |  | 
	
		|  | 
	
		|  |