This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

startup edit in lpc2138

hai all,

I m doing rtos programming which is based on osek standard for LPC2138.
In that i need to enter the supervisor mode for running the tasks & all my code must runs under svc mode. but main prog is running in user mode if i use the startup.s in the keil.
so i had changed the startup.s to run the main in svc mode by commenting the usermode stack initialization. Now it is running under SVC mode. but the problem is when i enter into IRQ mode i call some user functions through asm & changing the mode into SVC to save task stack back into IRQ mode , at that time the global variables are changed.Pls give some tech ass regarding this issue.(I need the global variables won't change )

Thanks in advance,

yos

Parents Reply Children
  • you will need to write a little assembly to switch from IRQ to SVC, manipulating the CPSR register. Check you processor manual to see where the processor mode bits are. Ho, and it is not likely to work as inline assembly. use embedded assembly instead, like this:

    void __asm irq_to_svc(void)
    {
       // assembly code goes here
    .
    .
    .
       BX LR
    }
    

  • Instead of writing "I need to run all tasks in SVC mode", it would be better if you write why you need to use SVC mode for the tasks, instead of running them in user mode. The quality of the answers you can be greatly affected by the motivations you can offer.

  • it would be better if you write why you need to use SVC mode for the tasks, instead of running them in user mode

    Exactly!

  • changing the modes of the processor at runtime , disabling & enabling the interrupts during context switch, allow the nesting of interrupts in that we use task stack or ISR stack to store.

  • interrupts during context switch

    not required. nested interrupts are disabled by default!

    allow the nesting of interrupts in that we use task stack or ISR stack to store

    this sounds a little dangerous to me. can you see why?

    non of this is a good reason to work in SVC mode. as stated already: stick to user mode except for handling processor exception. a context switch is indeed such a condition but it can be perfectly handled in IRQ mode. you are doing dangerous things out there. running all tasks in SVC allow them uncontrolled access to CPSR - it that your intention?

  • "changing the modes of the processor at runtime , disabling & enabling the interrupts during context switch, allow the nesting of interrupts in that we use task stack or ISR stack to store."

    This is a list of what you want to do, but there is still not any motivation.