当前位置:网站首页>RT thread migration to s5p4418 (I): scheduler
RT thread migration to s5p4418 (I): scheduler
2022-06-30 06:40:00 【Mnnk】
S5P4418,Cortex-A9 series .
Combined with the RT-Thread Kernel Implementation ( 6、 ... and ): Time slice and S5P4418 Bare metal development ( fourteen ):TIMER Code for .
SysTick & PendSV
RT-Thread The implementation of thread scheduling two core interrupts .
SysTick Update system timebase .PendSV Do context switching .
- SysTick stay S5P4418 of use timer0 Instead of . cycle 10ms, Note that the interrupt service function should clear the interrupt flag bit .
void SysTick_Config(){
// It's just a change of name
IP_RESET_REGISTER1 |= (1 << 4); // Close reset
TCFG0 |= (250 - 1); // PCLK = 200MHz 200000000 / 16 / 250 = 50000;
TCFG1 |= 0x4;
TCNTB0 = 500; // 500 = 10ms
TCON |= (1 << 1);
// vic_init(23, (u32)timer0_ISR); // register VIC
vic_init(23, (u32)SysTick_Handler); // register VIC
TINT_CSTAT |= (1 << 0); // Interrupt enable
TCON &= ~(1 << 1);
TCON |= ((1 << 3) | (1 << 0)); // Automatic reload , Start timer
}
void SysTick_Handler(void)
{
/* Enter interrupt */
rt_interrupt_enter();
rt_tick_increase();
TINT_CSTAT |= (1 << 5); // Clear interrupt flag
/* Leave interrupt */
rt_interrupt_leave();
}
- Choose another one that can replace PendSV The interrupt , because S5P4418 All interrupts on can be triggered by software , So choose one that nobody uses , I chose 63 Interrupt number . The key point is to modify the interrupt service program .
PendSV_Handler
- Coterx-M3 Scheduling in RT-Thread Kernel Implementation ( One ): Threads and scheduling It is more clearly described in . A few steps to switch contexts :
- Hardware auto save xPSR, PC, LR, R12 as well as R3‐R0 To the thread stack .
- Take out the source thread's psp, The top of the stack sp, preservation r4 - r11 To sp Point to . This completes the task of saving the above .
- Switch below , Take the... Of the thread to be run sp value , No sp register , load r4 - r11, then sp Write the value back to sp register .
- After exiting the interrupt , The hardware is automatically loaded from the stack xPSR, PC, LR, R12 as well as R3‐R0.
- and A9 There is no automatic save operation when responding to an interrupt , either MSP and PSP register . You can also press the above... When transplanting 4 Step by step .
- First step , preservation CPSR, PC, LR, R12 as well as R3‐R0 To the thread stack .CPU Get into IRQ After the model ,sp The register is in this mode r13_irq. The thread I set up runs in privileged mode , Its sp Registers should r13_svc. So first switch back to the mode before the interrupt .
- then push that 8 A register , Here we need to pay attention to the order , The next step is to explain .
- The second step , preservation r4 - r11, At this time, the mode is switched , It is already the stack of the source thread , direct push.
- The third step , Switch below , and M3 The operation is the same .
- Step four ,A9 The previous mode will be automatically saved when entering the interrupt CPSR To SPSR, When exiting an interrupt , If LDMFD Equal command band ’^’,CPSR Automatically written back by hardware . So recover PC, LR, R12 as well as R3‐R0 when , First of all, I will CPSR write in SPSR in , For the convenience of cpsr Value , When saving in the first step CPSR the last one push. meanwhile
struct exception_stack_frameMediumrt_uint32_t psrPut it on the top .
Other details will be added later .
engineering

边栏推荐
- Why does the verification code not refresh when clicked
- 原来你是这样的数组,终于学会了
- 1.2(补充)
- 1.9 - 存储器的分类
- Introduction to programming ape (11) -- structure
- 图片。。。。。
- Pay attention to this live broadcast and learn about the path to achieve the dual carbon goal of the energy industry
- Software tools_ Shortcut_ Operation summary
- 1.4 - fixed and floating point numbers
- GO安装以及配置(1)
猜你喜欢

Numpy中的四个小技巧

Analysis of startup process of gazebo multi computer simulation

Picture.....

Judge whether H5 is in wechat environment or enterprise wechat environment at both ends

Detailed description of methods in the interface

Win10 /11 开热点无法上网问题

Px4 control mode summary

Rhcsa day 3

1.3 - 码制

Idea add database
随机推荐
Simple example of class template
A complete performance test process
Gazebo installation, uninstall and upgrade
Numpy中的四个小技巧
Never forget the original intention, and be lazy if you can: C # operate word files
Using C language pure for loop to implement ilovey
Why does the verification code not refresh when clicked
ROS multi machine
Unable to access the Internet at win10 /11 hotspot
ES6 array
1.9 - Cache
ini解析學習文檔
Combat simulation system data
A small template (an abstract class, a complete process is written in a method, the uncertain part is written in the abstract method, and then the subclass inherits the abstract class, and the subclas
Use and principle of completionservice (source code analysis)
相关数据库问题提问。
1.8 - multi level storage
写一个C程序判断系统是大端字节序还是小端字节序
RT thread Kernel Implementation (I): threads and scheduling
神经网络入门