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

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [docs/] [datasheet/] [soc_pwm.adoc] - Diff between revs 60 and 64

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 60 Rev 64
Line 22... Line 22...
bit true color, to dim LCD back-lights or even for "analog" control. An external integrator (RC low-pass filter)
bit true color, to dim LCD back-lights or even for "analog" control. An external integrator (RC low-pass filter)
can be used to smooth the generated "analog" signals.
can be used to smooth the generated "analog" signals.
 
 
**Theory of Operation**
**Theory of Operation**
 
 
The PWM controller is activated by setting the _PWM_CT_EN_ bit in the module's control register _PWM_CT_. When this
The PWM controller is activated by setting the _PWM_CTRL_EN_ bit in the module's control register `CTRL`. When this
bit is cleared, the unit is reset and all PWM output channels are set to zero.
bit is cleared, the unit is reset and all PWM output channels are set to zero.
The 8-bit duty cycle for each channel, which represents the channel's "intensity", is defined via an 8-bit value. The module
The 8-bit duty cycle for each channel, which represents the channel's "intensity", is defined via an 8-bit value. The module
provides up to 15 duty cycle registers _PWM_DUTY0_ to _PWM_DUTY14_ (depending on the number of implemented channels).
provides up to 15 duty cycle registers `DUTY[0]` to `DUTY[14]` (depending on the number of implemented channels).
Each register contains the duty cycle configuration for 4 consecutive channels. For example, the duty cycle of channel 0
Each register contains the duty cycle configuration for 4 consecutive channels. For example, the duty cycle of channel 0
is defined via bits 7:0 in _PWM_DUTY0_. The duty cycle of channel 2 is defined via bits 15:0 in _PWM_DUTY0_.
is defined via bits 7:0 in `DUTY[0]`. The duty cycle of channel 2 is defined via bits 15:0 in `DUTY[0]`.
Channel 4's duty cycle is defined via bits 7:0 in _PWM_DUTY1_ and so on.
Channel 4's duty cycle is defined via bits 7:0 in `DUTY[1]` and so on.
 
 
[NOTE]
[NOTE]
Regardless of the configuration of _IO_PWM_NUM_CH_ all module registers can be accessed without raising an exception.
Regardless of the configuration of _IO_PWM_NUM_CH_ all module registers can be accessed without raising an exception.
Software can discover the number of available channels by writing 0xff to all duty cycle configuration bytes and
Software can discover the number of available channels by writing 0xff to all duty cycle configuration bytes and
reading those values back. The duty-cycle of channels that were not implemented always reads as zero.
reading those values back. The duty-cycle of channels that were not implemented always reads as zero.
 
 
Based on the configured duty cycle the according intensity of the channel can be computed by the following formula:
Based on the configured duty cycle the according intensity of the channel can be computed by the following formula:
 
 
_**Intensity~x~**_ = _PWM_DUTY_CHx_ / (2^8^)
_**Intensity~x~**_ = `DUTY[y](i*8+7 downto i*8)` / (2^8^)
 
 
The base frequency of the generated PWM signals is defined by the PWM core clock. This clock is derived
The base frequency of the generated PWM signals is defined by the PWM core clock. This clock is derived
from the main processor clock and divided by a prescaler via the 3-bit PWM_CT_PRSCx in the unit's control
from the main processor clock and divided by a prescaler via the 3-bit PWM_CTRL_PRSCx in the unit's control
register. The following prescalers are available:
register. The following prescalers are available:
 
 
.PWM prescaler configuration
.PWM prescaler configuration
[cols="<4,^1,^1,^1,^1,^1,^1,^1,^1"]
[cols="<4,^1,^1,^1,^1,^1,^1,^1,^1"]
[options="header",grid="rows"]
[options="header",grid="rows"]
|=======================
|=======================
| **`PWM_CT_PRSCx`**          | `0b000` | `0b001` | `0b010` | `0b011` | `0b100` | `0b101` | `0b110` | `0b111`
| **`PWM_CTRL_PRSCx`**        | `0b000` | `0b001` | `0b010` | `0b011` | `0b100` | `0b101` | `0b110` | `0b111`
| Resulting `clock_prescaler` |       2 |       4 |       8 |      64 |     128 |    1024 |    2048 |    4096
| Resulting `clock_prescaler` |       2 |       4 |       8 |      64 |     128 |    1024 |    2048 |    4096
|=======================
|=======================
 
 
The resulting PWM base frequency is defined by:
The resulting PWM base frequency is defined by:
 
 
_**f~PWM~**_ = _f~main~[Hz]_ / (2^8^ * `clock_prescaler`)
_**f~PWM~**_ = _f~main~[Hz]_ / (2^8^ * `clock_prescaler`)
 
 
 
 
.PWM register map
.PWM register map (`struct neorv32_pwm_t`)
[cols="<4,<4,<6,^2,<8"]
[cols="<4,<4,<6,^2,<8"]
[options="header",grid="all"]
[options="header",grid="all"]
|=======================
|=======================
| Address | Name [C] | Bit(s), Name [C] | R/W | Function
| Address | Name [C] | Bit(s), Name [C] | R/W | Function
.4+<| `0xfffffe80` .4+<| _PWM_CT_ <|`0` _PWM_CT_EN_    ^| r/w | PWM enable
.4+<| `0xfffffe80` .4+<| `NEORV32_PWM.CTRL` <|`0` _PWM_CTRL_EN_    ^| r/w | PWM enable
                                  <|`1` _PWM_CT_PRSC0_ ^| r/w .3+<| 3-bit clock prescaler select
                                            <|`1` _PWM_CTRL_PRSC0_ ^| r/w .3+<| 3-bit clock prescaler select
                                  <|`2` _PWM_CT_PRSC1_ ^| r/w
                                            <|`2` _PWM_CTRL_PRSC1_ ^| r/w
                                  <|`3` _PWM_CT_PRSC2_ ^| r/w
                                            <|`3` _PWM_CTRL_PRSC2_ ^| r/w
.4+<| `0xfffffe84` .4+<| _PWM_DUTY0_ <|`7:0`   ^| r/w <| 8-bit duty cycle for channel 0
.4+<| `0xfffffe84` .4+<| `NEORV32_PWM.DUTY[0]`  <|`7:0`   ^| r/w <| 8-bit duty cycle for channel 0
                                     <|`15:8`  ^| r/w <| 8-bit duty cycle for channel 1
                                     <|`15:8`  ^| r/w <| 8-bit duty cycle for channel 1
                                     <|`23:16` ^| r/w <| 8-bit duty cycle for channel 2
                                     <|`23:16` ^| r/w <| 8-bit duty cycle for channel 2
                                     <|`31:24` ^| r/w <| 8-bit duty cycle for channel 3
                                     <|`31:24` ^| r/w <| 8-bit duty cycle for channel 3
| ...     | ...      | ...              | r/w | ...
| ...     | ...      | ...              | r/w | ...
.4+<| `0xfffffebc` .4+<| _PWM_DUTY14_ <|`7:0`   ^| r/w <| 8-bit duty cycle for channel 56
.4+<| `0xfffffebc` .4+<| `NEORV32_PWM.DUTY[14]` <|`7:0`   ^| r/w <| 8-bit duty cycle for channel 56
                                      <|`15:8`  ^| r/w <| 8-bit duty cycle for channel 57
                                      <|`15:8`  ^| r/w <| 8-bit duty cycle for channel 57
                                      <|`23:16` ^| r/w <| 8-bit duty cycle for channel 58
                                      <|`23:16` ^| r/w <| 8-bit duty cycle for channel 58
                                      <|`31:24` ^| r/w <| 8-bit duty cycle for channel 59
                                      <|`31:24` ^| r/w <| 8-bit duty cycle for channel 59
|=======================
|=======================

powered by: WebSVN 2.1.0

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