Renesas M16C/6X -- Simple PWM Signal Generation Using DMA
1. Requirements
To generate a PWM output, we need to create a train of pulses with constant period and variable duty cycle.
The duty cycle, being the modulation is the pulse width.
Typically, a timer is used to maintain both the period and duty cycle
by toggling an output based on compare matches between the timer and timer registers.
The timer is reset at the end of the pulse’s period in preparation for generating the next pulse.
In this case, the number of PWM will be limited by the number of timers that can operate in PWM mode.
This application note illustrates another method to generate the PWM outputs,
using DMA transfers to create one or two PWM signals.
This can be an advantage when a particular timer (a ‘precious resource’)
with a certain function is needed for other purposes in a design.
Instead, a simpler timer can be used.
2. DMAC Operation
The operation of DMAC on an M16C/6x device is as follows:
- DMAC is initialized with a source address, a destination address, and a number for the amount of data to be transferred.
- The DMA ‘waits’ for a request signal which can be a software or hardware trigger signal.
- After a request signal is received, one byte or one word of data is transferred from the source address to the destination address.
- Depended on the DMA settings, either the source or destination address is incremented, or both addresses stay fixed.
- After a predefined number of data is transferred, the transfer can be repeated at the beginning or stopped.
A variable PWM signal will be created since we can change the source data as we please, and thus vary the duty cycle (pulse width).
We can also change the destination address.
The train of data can be output as an external signal of the MCU if we set the destination address to a specific output port.
3. How the PWM Signal is Created
We need to continuously maintain the pulse’s period and duty cycle.
To have the DMAC maintain the period we use a timer as the DMA request factor.
In the sample application we set up a timer to cause an underflow and then request a DMA transfer.
We can fine tune the signal at the destination output pin to have any level (high or low) at any specific time in one period.
In the following reasoning, a timer period is quantified as the time interval between each timer underflow.
This is Ttimer = PWM period / PWM resolution
To achieve a certain PWM resolution, say N (e.g. 255), we must transfer data N (255) times within one PWM period.
We will operate the DMAC in repeat mode to generate a continuous train of PWM signal.
In this mode, the whole set of data at the source address will be transferred again and again after the completion of the previous one.
Figure 1. PWM data is through some means apart from the DMA written to the data source buffer, pointed to by SARi.
This data is periodically transferred by the DMAC so that the signals at P4 behave the same way as PWM outputs with pre-defined duty cycle.
An array of data is shown which generate a PWM signal with 30% and 70% duty cycle at pin P4_0 and P4_1.
Up to 8 separate PWM signals can easily be generated in this example, with the same amount of MCU peripherals.
As shown in Figure 1, N data is transferred by N timer interrupts, and then the process is repeated.
N is the value in the TCRi register (Transfer Counter register) and is in fact the PWM resolution.
Data is transferred from the source address (in the SAR register) to the destination address (in the DAR register), which maps to P4.
Renesas M16C/6X -- Simple PWM Signal Generation Using DMA的更多相关文章
- Control an LM317T with a PWM signal
http://www.edn.com/design/analog/4363990/Control-an-LM317T-with-a-PWM-signal The LM317T from Nationa ...
- STM32的PWM输入模式设置并用DMA接收数据
参考 :STM32输入捕获模式设置并用DMA接收数据 PWM input mode This mode is a particular case of input capture mode. The ...
- Simple PWM to Analog Circuit (0-10vdc)
i just finished this simple circuit and am very satisfied with the result. The output is very stable ...
- STM32F4 -- How to use the DMA burst feature
Bits 15:13 Reserved, must be kept at reset value. Bits 12:8 DBL[4:0]: DMA burst length This 5-bit ve ...
- PWM DAC vs. Standalone
http://analogtalk.com/?p=534 http://analogtalk.com/?p=551 Posted by AnalogAdvocate on April 09, 2010 ...
- Make a DAC with a microcontroller's PWM timer
http://www.edn.com/design/analog/4337128/Make-a-DAC-with-a-microcontroller-s-PWM-timer Many embedded ...
- Generate stabilized PWM signals
A standard technique for generating analog voltages using µCs is to use a PWM output and filter the ...
- PWM DAC Low Pass Filtering
[TI博客大赛][原创]LM3S811之基于PWM的DAC http://bbs.ednchina.com/BLOG_ARTICLE_3005301.HTM http://www.fpga4fun.c ...
- How determine the RC time constant in PWM DAC low-pass filter?
how determine the RC time constant in PWM digital to analog low-pass filter? I 'm looking for the be ...
随机推荐
- swift3.0之后的Error处理
在之前的版本中,Swift中Error与OC中NSError没有关系.但是现在两者可以互相强转. 我们看看两者的区别:Error是一个实现Error协议的枚举或者结构体,对外能够获取的具体信息只有ra ...
- CF 1131B Draw!
Draw! Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Descriptio ...
- 银行卡号码校验算法(Luhn算法,又叫模10算法)
有时候在网上办理一些业务时有些需要填写银行卡号码,当胡乱填写时会立即报错,但是并没有发现向后端发送请求,那么这个效果是怎么实现的呢. 对于银行卡号有一个校验算法,叫做Luhn算法. 一.银行卡号码的校 ...
- 使用Sysmon和Splunk探测网络环境中横向渗透
当前很难在网络中探测攻击者横向渗透,其中原因有很难获取必要的日志和区别正常与恶意行为.本篇文章介绍通过部署Sysmon并将日志发送到SIEM来探测横向渗透. 工具: Sysmon + Splunk l ...
- 八、mini2440裸机程序之UART(1)简单介绍【转】
转自:http://blog.csdn.net/shengnan_wu/article/details/8298869 一.概述 S3C2440通用异步接收和发送(UART)提供了三 ...
- mitmproxy实践
首先附上github地址:https://github.com/mitmproxy/mitmprox,上面的内容永远是最新的 作为一名测试穿戴设备相关app的工程师,与数据打交道是常事,那么,如果想要 ...
- 安装.NET Framework返回1603错误的解决办法
昨天正在忙其它事情,实然同事向我反馈TFS上的文档无法浏览查看.第一反映是他的机器环境问题,让他试了下其它项目的文档也无法查看,后来在我电脑上也尝试了一下,果然无法查看项目文档,看来是TFS出了问题. ...
- PowerMockRunner和ActiveObjectsJUnitRunner
Jira的二次开发,需要作单元测试. 测试跟数据库连接的类,比如service类,需要在类上加@RunWith(ActiveObjectsJUnitRunner.class). 有时需要搭配mocki ...
- mysql innodb 行级锁升级
创建数据表test,表定义如下所示: CREATE TABLE `test` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(20) NO ...
- IntelliJ IDEA JRebel Maven Tomcat 实现热部署
一,JRebel 插件 获取与安装 直接在 IDEA 中操作获取 JRebel 插件 Paste_Image.png Paste_Image.png 安装完成,记得重启 IDEA 使刚才安装的插件生效 ...