| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| dmitrboristuk 
 
 
 Joined: 26 Sep 2020
 Posts: 73
 
 
 
			    
 
 | 
			
				| Problems with using BRA/BRW |  
				|  Posted: Thu Jan 23, 2025 1:08 am |   |  
				| 
 |  
				| The program uses two LUTs. One of them is used in the ISR, the second in the main code. The table used in the ISR works perfectly. But the table in the main code has no effect. The number is not extracted. Are there any recommendations for placing tables in program memory? There is also a PIC12LF1552 Silicon Errata and Data Sheet Clarification where 1.1 BRA/BRW have problems. I use a PIC16f1619. Have you encountered similar behavior? 
  	  | Code: |  	  | static int8 LUT_ISR[30]={0, 90, 0, 0...90, 45};
 static int8 LUT_MAIN[174]={0,8,16,67...34,56};
 
 | 
 |  | 
	
		|  | 
	
		| Ttelmah 
 
 
 Joined: 11 Mar 2010
 Posts: 19966
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu Jan 23, 2025 2:08 am |   |  
				| 
 |  
				| Critical question. What compiler version?????.
 Generally CCS will have fixes for problems like this (unless you use the device
 editor and turn them off), but sometimes when new issues are reported, these
 fixes may not appear for a few compiler versions.
 You say the lookup does not work. How are you testing this?. Are you sure
 the code is actually executing this part of the main?.
 |  | 
	
		|  | 
	
		| dmitrboristuk 
 
 
 Joined: 26 Sep 2020
 Posts: 73
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu Jan 23, 2025 2:27 am |   |  
				| 
 |  
				| 5.115 In the assembler code everything looks great
 I'll write more details later, I'm leaving
 
  	  | Code: |  	  | 
 int16 X, Y;
 int8 nomb;
 
 Y = 855 + main_lut[nomb] + X;
 
 | 
 |  | 
	
		|  | 
	
		| Ttelmah 
 
 
 Joined: 11 Mar 2010
 Posts: 19966
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu Jan 23, 2025 4:11 am |   |  
				| 
 |  
				| What you post refers to a different table to what you earlier showed. main_lut versus lut_main....
   
 Are you sure you have not gt something declared called main_lut, and hence
 it is not actually accessing the table you think?.....
 |  | 
	
		|  | 
	
		| Ttelmah 
 
 
 Joined: 11 Mar 2010
 Posts: 19966
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu Jan 23, 2025 8:16 am |   |  
				| 
 |  
				| That only applies if an interrupt occurs during the instruction. So try the experiment of disabling the interrupt before doing the table lookup. If is
 starts working, you have identified the problem.
 It is very unlikely that your chip has this problem. Somebody would have
 seen it if so, and it'd be in the errata for your chip.
 |  | 
	
		|  | 
	
		| dmitrboristuk 
 
 
 Joined: 26 Sep 2020
 Posts: 73
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu Jan 23, 2025 11:46 pm |   |  
				| 
 |  
				| Ttelmah As I was informed, the problem was solved by moving main_lut[nomb] to the next page of memory with the address 0x800. In the assembler code, two instructions were added: movlp 0x08 when calling and movlp 0x00 when returning. Well, there is a misunderstanding here: call has an 11-bit address and it does not need movlp.
 |  | 
	
		|  | 
	
		|  |