Discussion in "ARM Development" started by    Fejsu    Jun 9, 2009.
Tue Jun 09 2009, 02:45 am
#1
Hello,

I am trying to perform context switching using lpc2148 arm7 controller.The saving is working but when i try to load the next task the R14_IRQ register is not being with the same value as that of R14 User mode register.

Any suggestion?


Below is my code :

__inline void tc0 (void) __irq  {

		 //unsigned int ref_sp;
		 T0IR        = 1;                            // Clear interrupt flag
         VICVectAddr = 0;		                // Acknowledge Interrupt
	
if ( (pid>
0 && pcb_new[pid].head!=0 ) ){
		
	    //START CONTEXT SWITCH PROCESS/// 
	   // SAVE REGISTERS // pid=current_task
		
		ref_sp = pcb_new[pid].sp1;	 
		 __asm {
			  
	  
	 LDMFD R13!,{R0-R3,R12,R14};
	 LDR R13,=ref_sp;
	 LDR R13,[R13];
	 SUB R13,R13,#60;
	 STMIA R13,{R0-R14}^;
	 MRS R0,SPSR;
	 SUB R13,R13,#4;
	 STR R14,[R13];
	 ADD R13,R13,#4;
	 STMDB R13,{R0,R14};
	 	
		 	   }
		
	
		switch_task(); //TO FIND NEXT TASK 
		 	//Loading new task
		if (pcb_new[pid].state==1){
		                        
								ref_sp=pcb_new[pid].sp1;
							  
							  __asm{
							        						 //LOADING new PCB-->
 DURING CONTEXT SWITCH
						
								   
								   	LDR R13,=ref_sp;
									LDR R13,[R13];
									SUB R13,R13,#60;
									LDMDB R13,{R0,R14};
									MSR SPSR_CXSF,R0;
									LDMIA R13,{R0-R14}^;
									LDR R13,=PCB_IRQStack;
								    LDR R13,[R13];
									MOVS PC,R14;  -->
>
PROBLEM HERE R14_IRQ VALUE NOT EQUAL TO USER MODE R14.
									}
					              }
                                         
	   }
		}


Thanks


[ Edited Sat Jun 13 2009, 04:07 am ]
Sat Jun 13 2009, 04:11 am
#2
well i think this has been discussed earlier too, that you wont be able to access banked registers when switching from user mode to IRQ/FIQ mode. you can try changing the processor mode to user mode and then access R14 register, i am not sure how will it going to effect the whole process :-s

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

AngeloFoown
Sat Apr 13 2024, 12:17 pm
JamesLex
Sat Apr 13 2024, 05:23 am
RobertWah
Fri Apr 12 2024, 08:01 pm
solar_qcor
Fri Apr 12 2024, 08:38 am
Rosalvascuth
Thu Apr 11 2024, 06:07 am
WilliamAmazy
Wed Apr 10 2024, 10:13 pm
slm_pkPn
Wed Apr 10 2024, 08:43 pm
LaurenBramn
Wed Apr 10 2024, 02:08 pm