Giter VIP home page Giter VIP logo

Comments (7)

rayc345 avatar rayc345 commented on June 25, 2024

Not manually, For Armv7-M ISA based CPU like Cortex-M7, caller save registers (r0-r3,r12,LR(r14),PC(r15), xPSR) would be saved into stack by hardware, and r4-r9, r10,r11,SP would be saved by callee functions, save and restore instructions would be generated by compilers, so for C programmers, no manual procedure is required to save/restore contexts.

from threadx.

amgross avatar amgross commented on June 25, 2024

Hi @rayc345
Threadx context save/restore not only saves register, but also manages the option that while the interrupt happened something that requires context switch. For this case stuff needed to be stored on the stack and context restore returns from the interrupt to the scheduler instead of to the original point where the interrupt was called from.
And hence I think the answer to @maxkunes is that indeed it should be called from assembly code.

from threadx.

maxkunes avatar maxkunes commented on June 25, 2024

@amgross Thank you for the reply.

Honestly, I've been working with ThreadX for 3 years now without doing this, and I've yet to see anything that is obviously wrong.
Can you explain what behavior might be seen in theory without these calls? Maybe I have some intermittent bugs due to this that I haven't connected to anything else.

from threadx.

amgross avatar amgross commented on June 25, 2024

Hi @maxkunes ,
By 'without doing it' you mean you call it from C code or not calling it at all?

from threadx.

maxkunes avatar maxkunes commented on June 25, 2024

from threadx.

amgross avatar amgross commented on June 25, 2024

Surprisingly (for me), it seems like I was mistaken and there is no need for cortex M to use save/restore

6.2 Managed Interrupts
ISRs for Cortex-M can be written completely in C (or assembly language) without any
calls to _tx_thread_context_save or _tx_thread_context_restore. These ISRs are allowed
access to the ThreadX API that is available to ISRs.
ISRs written in C will take the form (where "your_C_isr" is an entry in the vector table):
void your_C_isr(void)
{
/* ISR processing goes here, including any needed function calls. */
}

So @rayc345 is correct

from threadx.

maxkunes avatar maxkunes commented on June 25, 2024

from threadx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.