difference between SWI and TRAP

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

difference between SWI and TRAP

3,927 次查看
LBdgWgt
Contributor I
Hello all,

I am working on a project about RTOS on HCS12 uC. I whave a doubt about what is the difference between SWI and TRAP, as far as I read, both are not affected by I bit in CCR, does someone know what is the difference between both (advantage and disadvantage). The RTOS need a simulated interrupt whent performing context switching.

thansk for any help,
标签 (1)
0 项奖励
回复
2 回复数

1,317 次查看
Steve
NXP Employee
NXP Employee
The instructions look similar but are intended for different uses. TRAP is in fact any unimplemented instruction in the S12(X) opcode map. So for S12 it is actually 202 opcodes and for S12XD it is 29 opcodes.
There are two disadvantages to using a TRAP instruction rather than SWI:
1/ The interrupt will be called by any of the unimplemented opcodes so any unintended software execution could cause a call to your RTOS kernel rather than being handled as an error.
2/ The TRAP availability is different on different CPUs (S12 vs S12X V1) and so code compatibility could be an issue for a flexible piece of code like an RTOS.
0 项奖励
回复

1,317 次查看
LBdgWgt
Contributor I
Thanks Steve for the very nice answer. I get it clearly now

regards,
0 项奖励
回复