211 lines
6.2 KiB
Markdown
211 lines
6.2 KiB
Markdown
sys_tick_swi
|
|
---
|
|
|
|
This example is used to configure ECLIC module
|
|
> + Support to register the proprietary ISR for specific requirement.
|
|
> + Support programmable IRQ-Level
|
|
>> reference `sys_irq_level_t`
|
|
|
|
> + Support programmable IRQ-Priority
|
|
>> reference `sys_irq_priority_t`
|
|
|
|
|
|
+ Configure SWI (Software Interupt) level
|
|
> The default level of system timer is `SYS_IRQ_LEVEL_L`
|
|
|
|
```c
|
|
// at main.c
|
|
/**
|
|
* The defualt level of system timer is SYS_IRQ_LEVEL_L
|
|
* ps. SYS_IRQ_LEVEL_LL/ SYS_IRQ_LEVEL_L/ SYS_IRQ_LEVEL_M
|
|
*/
|
|
#define CONFIG_IRQ_SWI_LEVEL SYS_IRQ_LEVEL_L
|
|
```
|
|
|
|
- Use `sys_register_IRQ()` to re-configure attributes of an interrupt
|
|
|
|
```c
|
|
sys_irq_attr_t irq_attr = { .disable_vector = false, };
|
|
|
|
irq_attr.trig_mode = SYS_IRQ_TRIGGER_LEVEL;
|
|
irq_attr.level = SYS_IRQ_LEVEL_L;
|
|
irq_attr.priority = SYS_IRQ_PRIORITY_MIDDEN;
|
|
sys_register_IRQ(SysTimer_IRQn, _mtim_handler, &irq_attr);
|
|
```
|
|
|
|
+ This example use message (in ISR) to figure out the relation of Level/Priority of ECLIC
|
|
> Logging message in ISR is misbehavior
|
|
|
|
- For logging message, the period of system tick MUST be more then `1-msec`
|
|
|
|
```
|
|
// at main.c,
|
|
/* The period MUST be more then 1 msec */
|
|
sys_config_systick(SYS_TICK_10_MS);
|
|
```
|
|
|
|
|
|
## Log
|
|
|
|
Use serial port with baudrate 115200, 8bit, no parity check.
|
|
|
|
+ If SWI level is equal to system timer
|
|
>```c
|
|
> // at main.c
|
|
> #define CONFIG_IRQ_SWI_LEVEL SYS_IRQ_LEVEL_L
|
|
>
|
|
> #define CONFIG_IRQ_SWI_PRIORITY SYS_IRQ_PRIORITY_MIDDEN
|
|
> ```
|
|
|
|
- Priority is the same
|
|
|
|
```
|
|
Feb 20 2025 12:42:39
|
|
This is a demo projec to configure ECLIC (IRQ Level: SWI == SysTim, Priority: SWI == SysTim)
|
|
-> _mtim_handler 0-th <--- enter ISR of system timer
|
|
<- _mtim_handler <--- leave system timer
|
|
=> _mswi_handler 1-th <--- enter ISR of SWI (wait for system timer finish)
|
|
<= _mswi_handler <--- leave SWI
|
|
-> _mtim_handler 1-th
|
|
<- _mtim_handler
|
|
=> _mswi_handler 2-th
|
|
<= _mswi_handler
|
|
-> _mtim_handler 2-th
|
|
<- _mtim_handler
|
|
=> _mswi_handler 3-th
|
|
<= _mswi_handler
|
|
-> _mtim_handler 3-th
|
|
<- _mtim_handler
|
|
=> _mswi_handler 4-th
|
|
<= _mswi_handler
|
|
-> _mtim_handler 4-th
|
|
<- _mtim_handler
|
|
=> _mswi_handler 5-th
|
|
<= _mswi_handler
|
|
done~~~
|
|
```
|
|
|
|
- If SWI priority is greater then system timer
|
|
|
|
```
|
|
Feb 20 2025 12:40:04
|
|
This is a demo projec to configure ECLIC (IRQ Level: SWI == SysTim, Priority: SWI > SysTim)
|
|
-> _mtim_handler 0-th <--- enter ISR of system timer
|
|
<- _mtim_handler <--- leave system timer
|
|
=> _mswi_handler 1-th <--- enter ISR of SWI (wait for system timer finish)
|
|
<= _mswi_handler <--- leave SWI
|
|
-> _mtim_handler 1-th
|
|
<- _mtim_handler
|
|
=> _mswi_handler 2-th
|
|
<= _mswi_handler
|
|
-> _mtim_handler 2-th
|
|
<- _mtim_handler
|
|
=> _mswi_handler 3-th
|
|
<= _mswi_handler
|
|
-> _mtim_handler 3-th
|
|
<- _mtim_handler
|
|
=> _mswi_handler 4-th
|
|
<= _mswi_handler
|
|
-> _mtim_handler 4-th
|
|
<- _mtim_handler
|
|
=> _mswi_handler 5-th
|
|
<= _mswi_handler
|
|
done~~~
|
|
```
|
|
|
|
- If SWI priority is lower then system timer
|
|
|
|
```
|
|
Feb 20 2025 12:44:14
|
|
This is a demo projec to configure ECLIC (IRQ Level: SWI == SysTim, Priority: SWI < SysTim)
|
|
-> _mtim_handler 0-th <--- enter ISR of system timer
|
|
<- _mtim_handler <--- leave system timer
|
|
=> _mswi_handler 1-th <--- enter ISR of SWI (wait for system timer finish)
|
|
<= _mswi_handler <--- leave SWI
|
|
-> _mtim_handler 1-th
|
|
<- _mtim_handler
|
|
=> _mswi_handler 2-th
|
|
<= _mswi_handler
|
|
-> _mtim_handler 2-th
|
|
<- _mtim_handler
|
|
=> _mswi_handler 3-th
|
|
<= _mswi_handler
|
|
-> _mtim_handler 3-th
|
|
<- _mtim_handler
|
|
=> _mswi_handler 4-th
|
|
<= _mswi_handler
|
|
-> _mtim_handler 4-th
|
|
<- _mtim_handler
|
|
=> _mswi_handler 5-th
|
|
<= _mswi_handler
|
|
done~~~
|
|
```
|
|
|
|
+ If SWI level is greater than system timer
|
|
>```c
|
|
> // at main.c
|
|
> #define CONFIG_IRQ_SWI_LEVEL SYS_IRQ_LEVEL_M
|
|
>
|
|
> #define CONFIG_IRQ_SWI_PRIORITY SYS_IRQ_PRIORITY_MIDDEN
|
|
> ```
|
|
|
|
```
|
|
Feb 20 2025 12:45:53
|
|
This is a demo projec to configure ECLIC (IRQ Level: SWI > SysTim, Priority: SWI == SysTim)
|
|
-> _mtim_handler 0-th <--- enter ISR of system timer
|
|
=> _mswi_handler 1-th <--- Nested interrupt by SWI
|
|
<= _mswi_handler <--- leave SWI
|
|
<- _mtim_handler <--- leave system timer
|
|
-> _mtim_handler 1-th
|
|
=> _mswi_handler 2-th
|
|
<= _mswi_handler
|
|
<- _mtim_handler
|
|
-> _mtim_handler 2-th
|
|
=> _mswi_handler 3-th
|
|
<= _mswi_handler
|
|
<- _mtim_handler
|
|
-> _mtim_handler 3-th
|
|
=> _mswi_handler 4-th
|
|
<= _mswi_handler
|
|
<- _mtim_handler
|
|
-> _mtim_handler 4-th
|
|
=> _mswi_handler 5-th
|
|
<= _mswi_handler
|
|
<- _mtim_handler
|
|
done~~~
|
|
```
|
|
|
|
+ If SWI level is lower then system timer
|
|
>```c
|
|
> // at main.c
|
|
> #define CONFIG_IRQ_SWI_LEVEL SYS_IRQ_LEVEL_LL
|
|
>
|
|
> #define CONFIG_IRQ_SWI_PRIORITY SYS_IRQ_PRIORITY_MIDDEN
|
|
> ```
|
|
|
|
```
|
|
Feb 20 2025 12:47:11
|
|
This is a demo projec to configure ECLIC (IRQ Level: SWI < SysTim, Priority: SWI == SysTim)
|
|
-> _mtim_handler 0-th <--- enter ISR of system timer
|
|
<- _mtim_handler <--- leave system timer
|
|
=> _mswi_handler 1-th <--- enter ISR of SWI (wait for system timer finish)
|
|
<= _mswi_handler <--- leave SWI
|
|
-> _mtim_handler 1-th
|
|
<- _mtim_handler
|
|
=> _mswi_handler 2-th
|
|
<= _mswi_handler
|
|
-> _mtim_handler 2-th
|
|
<- _mtim_handler
|
|
=> _mswi_handler 3-th
|
|
<= _mswi_handler
|
|
-> _mtim_handler 3-th
|
|
<- _mtim_handler
|
|
=> _mswi_handler 4-th
|
|
<= _mswi_handler
|
|
-> _mtim_handler 4-th
|
|
<- _mtim_handler
|
|
=> _mswi_handler 5-th
|
|
<= _mswi_handler
|
|
done~~~
|
|
```
|