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 ...
随机推荐
- Linux - 磁盘操作
Linux 磁盘常见操作 : df -Ph # 查看硬盘容量 df -T # 查看磁盘分区格式 df -i # 查看inode节点 如果inode用满后无法创建文件 du -h 目录 # 检测目录下所 ...
- C++--------------------------------指针和数组替换使用原因
马上要考试了,复习数据结构中,对C的指针不太了解,在严蔚敏<数据结构(C语言版)>中,发现p22定义顺序存储结构: typedef srtuct{ ElemType *elem; //存储 ...
- Spark笔记之使用UDAF(User Defined Aggregate Function)
一.UDAF简介 先解释一下什么是UDAF(User Defined Aggregate Function),即用户定义的聚合函数,聚合函数和普通函数的区别是什么呢,普通函数是接受一行输入产生一个输出 ...
- 工具类。父类(Pom文件)
ego_parent(pom文件) <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="ht ...
- 【干货】linux系统信息收集 ----检测是否被恶意程序执行了危险性命令
这些实战完全可以练习以下命令,已经找到需要观察的交互点,真实工作的时候,把数据都导入到自己U盘或者工作站内. 在kali 或者centos下训练都一样,关于kali教学,这里推荐掌控安全团队的课程:掌 ...
- 【Pyhon】获取文件MIME类型,根据文件类型自定义文件后缀
场景 下载样本,都是MD5命名的无后缀文件,需要自己手动查询然后修改文件后缀. 根据文件类型自定义后缀可以很方便地根据后缀判断用什么工具分析. 使用说明 libmagic 地址:https://pyp ...
- 『Matplotlib』数据可视化专项
一.相关知识 官网介绍 matplotlib API 相关博客 matplotlib绘图基础 漂亮插图demo 使用seaborn绘制漂亮的热度图 fig, ax = plt.subplots(2,2 ...
- Windows入侵问题排查
1.深入分析,查找入侵原因 1.1 检查帐户和弱口令 1.查看服务器已有系统或应用帐户是否存在弱口令 检查说明:主要检查系统管理员帐户.网站后台帐户.数据库帐户以及其他应用程序(FTP.Tomcao. ...
- apache本地配置多域名(wampserver本地配置多域名)
我们在本地开发时,一般是在浏览器输入 http://localhost/项目文件夹名来测试网页文件,你有没有想过在本地在浏览器输入你自己设定的一个域名进入项目文件夹中去,本地配置多域名可以测试二级域名 ...
- urbuntu12.04 ftp服务器搭建
1.安装ftp服务器: sudo apt-get install vsftpd 2..配置ftp 修改ftp的配置文件,该文件在/etc目录下,在终端中键入如下命令以打开配置文件: sudo vi / ...