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 ...
随机推荐
- Git Pull Failed: cannot lock ref 'refs/remotes/origin/xxxxxxxx': unable to resolve ref
1.xxxxxxxx代表目录名称,我要pull的目录是supman_creditmall_v5: 2.从代码库中pull代码时报这个错误,代码pull失败: 3.解决办法,看下图,删除文件后再pull ...
- 训练赛第二场E题 Cottage Village
题目大意:在一条X轴上,有若干个正方形,并且保证这些正方形的中心都在X轴上,然后输入n个正方形的中心的X坐标,和正方形的边长,现在要再插入一个正方形,要求是,新插入的正方形至少要有一条边与原来的正方形 ...
- Nessus扫描策略
本篇将简单介绍下Nessus的扫描策略设置.选用plugins及如何使用定制的策略来进行扫描任务. Step 1: 启动Nessus服务 root@kali:~# /etc/init.d/nessus ...
- artDialog学习之旅(一)
接口 配置参数 content: {消息内容,支持HTML} title: {标题.默认:'提示'} lock: {是否锁定屏幕. 默认:false} width: {宽度,支持em等单位. 默认:' ...
- 【ARTS】01_05_左耳听风-20181210~1216
ARTS: Algrothm: leetcode算法题目 Review: 阅读并且点评一篇英文技术文章 Tip/Techni: 学习一个技术技巧 Share: 分享一篇有观点和思考的技术文章 Algo ...
- Route Between Two Nodes in Graph
Given a directed graph, design an algorithm to find out whether there is a route between two nodes. ...
- ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 的解决办法
更换mysql数据目录后出现ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql ...
- 去除Android APP里面的广告
如何去除Android游戏软件中的广告:很多时候,我们下载好一款Andriod游戏软件,却被游戏软件中的广告弄的很烦.不停跳动的广告让人觉得非常不爽,而且在玩游戏的时候,还有可能点击到广告,中断游戏. ...
- SqlServer代理作业
最近一直在学习SqlServer 作业方面的知识,总结一下. 一:作业存在的库. msdb use msdb Msdb数据库是代理服务数据库,为其报警.任务调度和记录操作员的操作提供存储空间. 二: ...
- LOJ 10127 -「一本通 4.3 练习 1」最大数
题面 题目描述 给定一个正整数数列 $a_1, a_2, a_3, \dots , a_n$,每一个数都在 0~p-1之间.可以对这列数进行两种操作: 添加操作:向序列后添加一个数,序列长度变成 n+ ...