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 ...
随机推荐
- Loadrunner里面的深入理解Resource 的 0和1
最近在倒腾loadrunner,发现一些非常有意思的配置项,也许同学们平时去玩的时候,没有注意这些点.我也查阅了网上的帖子,说的都不够详细~操作起来的话,同学们也只是看到文字的描述,并不能发现区别.今 ...
- 【CTF WEB】XSS-https://alf.nu/alert1
XSS练习平台 https://alf.nu/alert1 Warmup 1");alert(1)// Adobe 1");alert(1)// JSON </script& ...
- 配置Eclipse编写HTML/JS/CSS/JSP页面的自动提示
我们平时用eclipse开发jsp页面时智能提示效果不太理想,今天用了两个小时发现了eclipse也可以像Visual Studio 2008那样完全智能提示HTML/JS/CSS代码,使用eclip ...
- Java封装概述
1.封装概述 private public 2.实现封装 例子: package com.java1995; public class Student { private String name; ...
- Batch Normalization 与 Caffe中的 相关layer
在机器学习领域,通常假设训练数据与测试数据是同分布的,BatchNorm的作用就是深度神经网络训练过程中, 使得每层神经网络的输入保持同分布. 原因:随着深度神经网络层数的增加,训练越来越困难,收敛越 ...
- CentOS 6 安装chromium
由于centos 6对C++11支持不足的缘故,目前chromium已经不再支持CentOS 6系列. 这里介绍如何在centos 6系列安装chromium. 1.添加chromium源 cd /e ...
- Python Extension 编译问题
Python 的一大好处是调用C扩展程序相当方便,但是 Windows 下的话,编译器版本是一个大问题.以Python27为例,官方版本时采用VC2008编译的.在setup.py中添加Extensi ...
- rabbitmq 相关
Exchange 在上一节我们看到生产者将消息投递到Queue中,实际上这在RabbitMQ中这种事情永远都不会发生.实际的情况是,生产者将消息发送到Exchange(交换器,下图中的X),由Exch ...
- Angular 5项目
Angular 5项目 如果您正在使用angular, 但是没有好好利用angular cli的话, 那么可以看看本文. Angular CLI 官网: https://github.com/angu ...
- linux shell 脚本攻略学习12--文件权限详解,chmod命令详解,chown命令详解,chattr命令详解
文件权限详解 一.chmod命令详解 文件权限和所有权是Unix/Linux文件系统最显著的特征之一.linux中的每一个文件都与多种权限类型相关联,在这些权限中主要分类为3种: 用户(User)是文 ...