This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28379D :A context switch for the task requires the entire execution context to saved, implement the Stack pointer and Programm counter for Real time Scheduler, with static allocate memory

Part Number: TMS320F28379D

Hello to all,
I'm currently programming a real time scheduler (RTOS) and for each task that allocates a static memory. I need to configure the stack pointer and the program counter to go back to where my program stopped and continue from that point. But I don't know how to do this with the TMS320F28379D, and I don't know the Assembler language. I have an example that works perfectly on the AVR microcontroller that I will attach here. I am really new in embedded and real time systems. The TCB (Task Control Block) contains a pointer to the stack and a variable for the status register. To make me understand better , here are my questions: 

  • A context switch for the task  requires the entire execution context to saved, how can i implement this? 
  • How built a atomic operation section in c with code composer studio? The Atomic section is used to create an uninterrupted section of the code.

I tried to look at how FreeRtos did this but I think the code is a bit too complicated for me to understand. That's why I'm asking you if anyone has already done it or knows how to make it work more easily according to the attached template. Any help will be welcome.

Thank for support

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
typedef struct TCBlock {
uint8_t task_id;
State state;
Priority priority;
uint8_t sreg;
uint8_t * sp;
uint8_t stack[STACK_SIZE];
} TCBlock;
#define stack_push(r) asm volatile("push r"#r)
#define stack_pop(r) asm volatile("pop r"#r)
ISR(TIMER0_OVF_vect) __attribute__ ((naked, hot));
ISR(TIMER0_OVF_vect) {
stack_push(31);
stack_push(30);
stack_push(29);
stack_push(28);
stack_push(27);
stack_push(26);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

best regard 

cabrel