CCS5中的历程:
#include <msp430f5529.h>
char TxString;
char RxString;
void main(void)
{
WDTCTL = WDT_ADLY_1000; // WDT 1000ms, ACLK, interval timer
SFRIE1 |= WDTIE; // Enable WDT interrupt
P1OUT &= ~0x01; // Clear P1.0 LED
P1DIR |= BIT0;
P3SEL |= BIT3+BIT4; // P3.3,4 = USCI_A0 SPI Option
P2DIR |= BIT7; // P2.7 UCA0CLK
P2SEL |= BIT7;
UCA0CTL1 |= UCSWRST; // **Put state machine in reset**
UCA0CTL0 = UCMST+UCSYNC+UCCKPL+UCMSB; // 3-pin, 8-bit SPI master
// Clock polarity high, MSB
UCA0CTL1 = UCSSEL_2; // SMCLK
UCA0BR0 = 0x02; // /2
UCA0BR1 = 0x00; //
UCA0MCTL = 0x00; // No modulation
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
DMACTL0 = DMA1TSEL_16+DMA0TSEL_17; // DMA0 - UCA0TXIFG
// DMA1 - UCA0RXIFG
// Setup DMA0
__data16_write_addr((unsigned short) &DMA0SA,(unsigned long) &TxString);
// Source block address
__data16_write_addr((unsigned short) &DMA0DA,(unsigned long) &UCA0TXBUF);
// Destination single address
DMA0SZ = 1; // Block size
DMA0CTL = DMASRCINCR_3+DMASBDB+DMALEVEL; // inc src
// Setup DMA1
__data16_write_addr((unsigned short) &DMA1SA,(unsigned long) &UCA0RXBUF);
// Source block address
__data16_write_addr((unsigned short) &DMA1DA,(unsigned long) &RxString);
// Destination single address
DMA1SZ = 1; // Block size
DMA1CTL = DMADSTINCR_3+
DMASBDB+DMALEVEL; // inc dst
TxString = RxString = 0; // Clear TxString
// Clear RxString
__bis_SR_register(LPM3_bits + GIE); // Enter LPM3 w/ interrupts
__no_operation(); // Required only for debugger
}
数据手册上寄存器DMA1CTL没有DMASBDB这一位啊???
还有手册手写的DMALEVEL=1选择高电平触发,只能在DMAE0作为外部触发源的情况下使用。但是这个历程触发源是UCA0TXIFG和UCA0RXIFG,为什么还把DMALEVE置位??
此帖出自
小平头技术问答
数据手册中是有定义的。第六和第七位,如上图
下面是头文件中的定义:总共4种传输方式,所以用了下面的定义方法:
#define DMASWDW (0*0x0040u) /* DMA transfer: source word to destination word */
#define DMASBDW (1*0x0040u) /* DMA transfer: source byte to destination word */
#define DMASWDB (2*0x0040u) /* DMA transfer: source word to destination byte */
#define DMASBDB (3*0x0040u) /* DMA transfer: source byte to destination byte */
一周热门 更多>