time base asm

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

time base asm

跳至解决方案
858 次查看
283230333
Contributor III

I got a example project from the support. There are some code which I don't  know the function of the code in the project. The code is below.

 

# tbs_main_asm.s - Time Base example

# Rev 1 Aug 27 2004 S Mihalik

# Copyright Freescale Semiconductor, Inc 2004 All rights reserved.

 

 

 

.globl tbs_main_asm

 

 

.text

tbs_main_asm: 

                      # INITIALIZE TIME BASE=0

  e_li      r4, 0       # Load immediate data of 0 to r4

  mttbu   r4    # Move r4 to TBU

  mttbl   r4          # Move r4 to TBL

  # ENABLE TIME BASE

  mfhid0  r5    # Move from spr HID0 to r5 (copies HID0)

  e_li      r4, 0x4000  # Load immed. data of 0x4000 to r4

  or      r5, r4, r5  # OR r4 (0x0000 4000) with r4 (HID0 value)

  mthid0  r5          # Move result to HID0

                      # EXECUTE SOME CODE

  e_nop

  e_nop

  e_nop

  e_nop

                      # RECORD TBL

  mftbl   r5          # Move TBL to r5 to store TBL value

 

  e_li r4, 0

  e_li r5, 0

  mtmsr r4

  mfmsr r4

  wrteei 1

  mfmsr r5

 

  se_blr                 # (Set a breakpoint here and read r5)

标签 (1)
0 项奖励
1 解答
676 次查看
martin_kovar
NXP Employee
NXP Employee

Hi,

the functionality of this code is comprehensibly described in the code comments.

First stage initialize registers TBU and TBL to value 0. Second stage writes 1 to TBEN bit. This enables Time Base (counter implemented in core). Then four nop instructions are executed and value in TBL register is copied to the register R5.

At last R4 and R5 are set to 0, MSR register is set to 0 and wrteei enables interrupts. Last instruction jumps to the address which is in LR register.

Regards,

Martin

在原帖中查看解决方案

0 项奖励
3 回复数
677 次查看
martin_kovar
NXP Employee
NXP Employee

Hi,

the functionality of this code is comprehensibly described in the code comments.

First stage initialize registers TBU and TBL to value 0. Second stage writes 1 to TBEN bit. This enables Time Base (counter implemented in core). Then four nop instructions are executed and value in TBL register is copied to the register R5.

At last R4 and R5 are set to 0, MSR register is set to 0 and wrteei enables interrupts. Last instruction jumps to the address which is in LR register.

Regards,

Martin

0 项奖励
676 次查看
283230333
Contributor III

Thank you very much for your reply. I also want to know the function of this code , what kind of role it can achieve? I can't find any information from the reference manual of MPC5644A. Could you give me some reference documents ? Thank you very much again!

0 项奖励
676 次查看
martin_kovar
NXP Employee
NXP Employee

Hi,

in general it can be used for example for time measuring. In fact Time Base is very precise counter which is implemented in the core. In your case I am not able to tell you why is this code used in your project because I do not have it.

If you want some information about time base, try to look at the core reference manual.

http://cache.freescale.com/files/32bit/doc/ref_manual/e200z4RM.pdf?fsrch=1&sr=1&pageNum=1

Regards,

Martin

0 项奖励