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

Sazrfwh
Mon Oct 07 2024, 10:00 am
Trefbed
Mon Oct 07 2024, 06:26 am
Trefyxx
Mon Oct 07 2024, 06:04 am
Lazrbpm
Mon Oct 07 2024, 04:11 am
Cazrlev
Sun Oct 06 2024, 10:49 pm
Anya75sa
Sun Oct 06 2024, 08:22 pm
Daviddek
Sun Oct 06 2024, 06:50 pm
AlfonsoWef
Sun Oct 06 2024, 05:08 pm