free 8051 Microcontroller Projects AVR PIC Microcontroller Projects Tutorials Ebooks Libraries, interfacing tutorials, lcd tutorial, stepper motor, dc motor 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems

 
8051 microcontroller 8051 microcontroller
Forums

Rickey's World :: Discussion Forums :: Discuss and Learn :: ARM Development
 
<< Previous thread | Next thread >>
CONTEXT SWITCH ARM 7 RTOS
Moderators: Ajay Bhargav, Arun Kumar V, pdi33, Shailesh NAYAK, ۞ TPS ۞, shyam, sashijoseph, ExperimenterUK, DavesGarage
Author Post
Fejsu
Mon Jun 08 2009, 02:15PM
 User Offline
Registered Member #15054
Joined: Mon Feb 09 2009, 01:49AM

Posts: 12
Thanked 0 times in 0 posts
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 :

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 Fri Jun 12 2009, 03:37PM ]

:mad
Back to top

Ajay Bhargav
Fri Jun 12 2009, 03:41PM
Rickey's World Admin

 User Offline

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 7542
Thanked 1330 times in 1254 posts
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

www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top

 

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System

8051 Microcontroller Projects 8051 AVR tutorials PIC microcontroller, 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems