OpenCores
URL https://opencores.org/ocsvn/neorv32/neorv32/trunk

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [docs/] [datasheet/] [soc_gptmr.adoc] - Blame information for rev 73

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 67 zero_gravi
<<<
2
:sectnums:
3
==== General Purpose Timer (GPTMR)
4
 
5
[cols="<3,<3,<4"]
6
[frame="topbot",grid="none"]
7
|=======================
8
| Hardware source file(s): | neorv32_gptmr.vhd |
9
| Software driver file(s): | neorv32_gptmr.c |
10
|                          | neorv32_gptmr.h |
11
| Top entity port:         | none |
12 73 zero_gravi
| Configuration generics:  | _IO_GPTMR_EN_ | implement general purpose timer when _true_
13 67 zero_gravi
| CPU interrupts:          | fast IRQ channel 12 | transmission done interrupt (see <<_processor_interrupts>>)
14
|=======================
15
 
16
 
17
**Theory of Operation**
18
 
19
The general purpose timer module provides a simple yet universal 32-bit timer. The timer is implemented if
20
_IO_GPTMR_EN_ top generic is set _true_. It provides a 32-bit counter register (`COUNT`) and a 32-bit threshold
21
register (`THRES`). An interrupt is generated whenever the value of the counter registers matches the one from
22
threshold register.
23
 
24
The timer is enabled by setting the _GPTMR_CTRL_EN_ bit in the device's control register `CTRL`. The `COUNT`
25
register will start incrementing at a programmable rate, which scales the main processor clock. The
26
pre-scaler value is configured via the three _GPTMR_CTRL_PRSCx_ control register bits:
27
 
28
.GPTMR prescaler configuration
29
[cols="<4,^1,^1,^1,^1,^1,^1,^1,^1"]
30
[options="header",grid="rows"]
31
|=======================
32
| **`GPTMR_CTRL_PRSCx`**      | `0b000` | `0b001` | `0b010` | `0b011` | `0b100` | `0b101` | `0b110` | `0b111`
33
| Resulting `clock_prescaler` |       2 |       4 |       8 |      64 |     128 |    1024 |    2048 |    4096
34
|=======================
35
 
36
The timer provides two operation modes that are configured by the _GPTMR_CTRL_MODE_ control register bit:
37
if _GPTMR_CTRL_MODE_ is cleared (`0`) the timer operates in _single-shot mode_. As soon as `COUNT` matches
38
`THRES` an interrupt request is generated and the timer stops operation (i.e. it stops incrementing). If
39
_GPTMR_CTRL_MODE_ is set (`1`) the timer operates in _continuous mode_. When `COUNT` matches `THRES` an interrupt
40
request is generated and `COUNT` is automatically reset to all-zero before continuing to increment.
41
 
42
[NOTE]
43
Disabling the timer will not clear the `COUNT` register. However, it can be manually reset at any time by
44
writing zero to it.
45
 
46
 
47
**Timer Interrupt**
48
 
49 69 zero_gravi
The timer interrupt is triggered when the timer is enabled and `COUNT` matches `THRES`. The interrupt
50 73 zero_gravi
remains pending until explicitly cleared by writing zero to the according <<_mip>> CSR bit.
51 67 zero_gravi
 
52
 
53
.GPTMR register map (`struct NEORV32_GPTMR`)
54
[cols="<2,<2,<4,^1,<7"]
55
[options="header",grid="all"]
56
|=======================
57
| Address | Name [C] | Bit(s), Name [C] | R/W | Function
58 69 zero_gravi
.5+<| `0xffffff60` .5+<| `NEORV32_GPTMR.CTRL` <|`0` _GPTMR_CTRL_EN_    ^| r/w <| Timer enable flag
59 67 zero_gravi
                                              <|`1` _GPTMR_CTRL_PRSC0_ ^| r/w .3+| 3-bit clock prescaler select
60
                                              <|`2` _GPTMR_CTRL_PRSC1_ ^| r/w
61
                                              <|`3` _GPTMR_CTRL_PRSC2_ ^| r/w
62
                                              <|`4` _GPTMR_CTRL_MODE_  ^| r/w <| Counter mode: `0`=single-shot, `1`=continuous
63
| `0xffffff64` | `NEORV32_GPTMR.THRES` |`31:0` | r/w | Threshold value register
64
| `0xffffff68` | `NEORV32_GPTMR.COUNT` |`31:0` | r/w | Counter register
65
|=======================

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.