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.

时间: 2025-01-04 01:56:12

Renesas M16C/6X -- Simple PWM Signal Generation Using DMA的相关文章

STM32的PWM输入模式设置并用DMA接收数据

STM32的PWM输入模式设置并用DMA接收数据 项目中需要进行红外学习,如果采用输入捕获的方式,因为定时器只能捕获上升沿或者下降沿, 所以只能获得周期,而不能得到具体的红外波的高低电平的时间. 所以采用PWM输入的方式进行捕获. 采用的是PA8脚,对应TIM1的通道1. /********************************************************************* * 函数 *************************************

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 and extremely linear! just though id share as i didn't find much on parallax's forums when i was searching for this configuration. Also any suggestio

Make a DAC with a microcontroller's PWM timer

Many embedded-microcontroller applications require generation of analog signals. An integrated or stand-alone DAC fills the role. However, you can often use PWM signals for generating the required analog signals. You can use PWM signals to create bot

Generate stabilized PWM signals

A standard technique for generating analog voltages using µCs is to use a PWM output and filter the signal with a simple RC filter (Figure 1). The voltage of the PWM signal is directly proportional to the µC's supply voltage, so it is not necessarily

The Secret Mixed-Signal Life of PWM Peripherals

The Secret Mixed-Signal Life of PWM Peripherals Pulse-width modulation (PWM) peripherals have enjoyed a long association with microcontrollers and power control, starting with motor control and power conversion. For the most part, these applications

how to generate an analog output from a in-built pwm of Atmega 32AVR microcontrloller?

how to generate an analog output from a in-built pwm of Atmega 32AVR microcontrloller? you need a resistor, a capacitor and an opamp. opamp is not really necessary when you are driving a mosfet, but will make life a bit easier. just be aware, that th

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 best RC time constant and its reason in a PWM to convert digital signal to analog based on duty-cycle and frequency and other parameters. PWM frequency

An Isolated DAC Using PWM Output

An Isolated DAC Using PWM Output Arduino‘s (ATmega328P) PWM outputs via analogWrite can be conveniently turned into analog voltage levels through the use of simple RC filters. Since the PWM outputs are not isolated, using them to drive other devices

linux signal 处理

v/:* {behavior:url(#default#VML);} o/:* {behavior:url(#default#VML);} w/:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} Normal 0 7.8 pt 0 2 false false false EN-US ZH-CN X-NONE /* Style Definitions */ table.MsoNormalTable {mso-s