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 ...
随机推荐
- Mysql锁机制简单了解一下
历史文章推荐: 可能是最漂亮的Spring事务管理详解 面试中关于Java虚拟机(jvm)的问题看这篇就够了 Java NIO 概览 关于分布式计算的一些概念 一 锁分类(按照锁的粒度分类) Mysq ...
- 在pycharm和tensorflow环境下运行nmt
目的是在pycharm中调试nmt代码,主要做了如下工作: 配置pycharm编译环境 在File->Settings->Project->Project Interpreter 设 ...
- Longest Words
Given a dictionary, find all of the longest words in the dictionary. Example Given { "dog" ...
- nagios使用问题的解决方案
通过web界面修改某个服务时报错例如对某个服务进行临时安排其执行时间,或者不让它发警告,web页面上都有这样的设置.但是常常会有错误信息如下: Could not open command file ...
- elasticsearch常见异常及解决办法
报错信息:Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 20602552 ...
- js字符串操作之substr与substring
substr和substring两个都是截取字符串的. 两者有相同点,如果只是写一个参数,两者的作用都是一样的:就是截取字符串当前下标以后直到字符串最后的字符串片段. 例如: `var a=" ...
- 移动网络简介与RRC
1.移动网络简介 1G:表示第一代移动通讯技术,以模拟技术为基础的蜂窝无线电话系统,如现在已经淘汰的模拟移动网.1G无线系统在设计上只能传输语音流量,并受到网络容量的限制. 2G:第二代手机通信技术规 ...
- flask你一定要知道的上下文管理机制
前引 在了解flask上下文管理机制之前,先来一波必知必会的知识点. 面向对象双下方法 首先,先来聊一聊面向对象中的一些特殊的双下划线方法,比如__call__.__getattr__系列.__get ...
- vue组件库(一):前期准备工作
前言 将近期项目内自行开发一个vue组件,做个总结,记录下自己的思维过程~~~ 正文 接到这个任务后,还是要做些准备工作的. 主要内容如下: 1.优化下所在团队前端开发流程 服务器搭建gitlab,采 ...
- salesforce
salesforce&apex salesforce开发的小心得 salesforce零基础学习(七十七)队列的实现以及应用 摘要: 队列和栈简单的区别为栈是后进先出,队列是先进先出.队列也是 ...