Please select To the mobile version | Continue to access the desktop computer version

OrangePi

 Login            
 Register            
Search
Hot search: orangepi
View: 999|Reply: 5

[Bare metal] Reading the 64-bit counter

[Copy link]

2

Threads

3

Posts

10

Credits

Novice

Rank: 1

Credits
10
Post time 2018-6-15 19:20:29 | Show all posts |Read mode
Edited by rpidmx512 at 2018-6-15 12:23

Example for how to read the 64-bit counter

  1. .macro FUNC name
  2. .text
  3. .code 32
  4. .global \name
  5. \name:
  6. .endm

  7. FUNC h3_read_cnt64
  8.         mov        r2, #0x1e00
  9.         mov r0, #2
  10.         movt r2, #0x1f0
  11.         str r0, [r2,#0x80]
  12. 1:
  13.         ldr r3, [r2,#0x80]
  14.         tst r3, #2
  15.         bne 1b
  16.         ldrd r0,r1,[r2,#0x84]
  17.         bx lr
Copy the Code

9

Threads

27

Posts

286

Credits

Intermediate member

Rank: 3Rank: 3

Credits
286
Post time 2018-6-30 14:12:12 | Show all posts
dmx512 replied at 2018-6-27 00:58
What is this code used for ?

It's used for reading the 64 bit counter.

I was using the memory mapped register method for a system timer until I realised that just using the coprocessor interface for it was far simpler.
That single line I provided reads the 64 bit counter via the coprocessor interface instead of the memory mapped interface. That's all. It grabs the whole 64 bits at once and puts them into two registers. My example uses a1 and a2, or if you like R0 and R1. Same thing. I believe they cn be any general purpose registers though.


9

Threads

27

Posts

286

Credits

Intermediate member

Rank: 3Rank: 3

Credits
286
Post time 2018-6-23 09:45:36 | Show all posts
Edited by ImmortanJoe at 2018-6-23 09:48

    MRRC   p15, 0, a1, a2, c14

copypasted from my code. a1 is low word. a2 is high word.
e:This is for the H3. It'd probably be similar on other SoCs.

16

Threads

35

Posts

387

Credits

Intermediate member

Rank: 3Rank: 3

Credits
387
Post time 2018-6-27 00:58:46 | Show all posts
  1. MRRC   p15, 0, a1, a2, c14
Copy the Code

What is this code used for ?

9

Threads

27

Posts

286

Credits

Intermediate member

Rank: 3Rank: 3

Credits
286
Post time 2018-7-1 10:51:28 | Show all posts
Edited by ImmortanJoe at 2018-7-1 10:59

Besides the H3 datasheet, the following documents are extremely useful regarding working with the H3:

* ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition
* Cortex -A7 MPCore Technical Reference Manual
* CoreLink GIC-400 Generic Interrupt Controller Technical Reference Manual
* Allwinner DE2.0 Specification
* Enhanced Host Controller Interface Specification for Universal Serial Bus
* i.MX 6Dual/6Quad Applications Processor Reference Manual (for the graphics hardware)
e: Forgot to say before the MPCore TRM is where a lot of useful things are like coprocessor interface information. The H3 core doesn't really seem to have been altered from the A7 MPCore design in any significant way.

16

Threads

35

Posts

387

Credits

Intermediate member

Rank: 3Rank: 3

Credits
387
Post time 2018-7-12 03:18:20 | Show all posts
ImmortanJoe replied at 2018-6-30 07:12
It's used for reading the 64 bit counter.

I was using the memory mapped register method for a sys ...

This is great information. Thank you!
You have to log in before you can reply Login | Register

Points Rules

Archiver|Mobile edition|Darkroom|OrangePi En ( 粤ICP备14086627号-2

2019-5-22 05:40 GMT+8 , Processed in 0.028695 second(s), 23 queries .

Powered by Discuz! X3.2

© 2014-2015 orangepibbs en.

Quick Reply To Top Return to the list