需要通过端口px快速接收并行数据,即每个clk周期传输一个字节数据,clk频率3M至6M,可否用clk作为DMA触发,通过DMA将端口数据快速移至RAM(每次640字节)。如何实。430主频24M.
Hardy Hu:
不知道你使用的是哪一款MCU,下面是F5438A的DMA例程,因为MSP430各个系列DMA操作差别不大,可以做个参考,也许这个能够帮助到你。
//******************************************************************************
// MSP430F543xA Demo – DMA0, Repeated Block to-from RAM, Software Trigger
//
// Description: A 16 word block from 1C00-1C1Fh is transfered to 1C20h-1C3fh
// using DMA0 in a burst block using software DMAREQ trigger.
// After each transfer, source, destination and DMA size are
// reset to inital software setting because DMA transfer mode 5 is used.
// P1.0 is toggled durring DMA transfer only for demonstration purposes.
// ** RAM location 0x1C00 – 0x1C3F used – make sure no compiler conflict **
// ACLK = REFO = 32kHz, MCLK = SMCLK = default DCO 1048576Hz
//
// MSP430F5438A
// —————–
// /|\| XIN|-
// | | | 32kHz
// –|RST XOUT|-
// | |
// | P1.0|–>LED
//
// M. Morales
// Texas Instruments Inc.
// June 2009
// Built with CCE v3.1 Build 3.2.3.6.4 & IAR Embedded Workbench Version: 4.11B
//******************************************************************************
#include "msp430x54xA.h"
void main(void)
{
WDTCTL = WDTPW+WDTHOLD; // Stop WDT
P1DIR |= 0x01; // P1.0 output
__data16_write_addr((unsigned short) &DMA0SA,(unsigned long) 0x1C00);
// Source block address
__data16_write_addr((unsigned short) &DMA0DA,(unsigned long) 0x1C20);
// Destination single address
DMA0SZ = 16; // Block size
DMA0CTL = DMADT_5+DMASRCINCR_3+DMADSTINCR_3; // Rpt, inc
DMA0CTL |= DMAEN; // Enable DMA0
while(1)
{
P1OUT |= 0x01; // P1.0 = 1, LED on
DMA0CTL |= DMAREQ; // Trigger block transfer
P1OUT &= ~0x01; // P1.0 = 0, LED off
}
}