Other Parts Discussed in Thread: MSP430F5308
Hello all,
to achieve a 1 MBit/s SPI data rate with the MSP430F5308, I would rather use DMA to fill the transmit buffer and fetch the data from the receive buffer instead of going the normal way via an ISR. The ISR would have a hard time, given that at 25 MHz, it would run every 200 MCLK ticks. What´s more: I need to transfer 16 bit SPI data (i.e. 2x8 bits), and I understand from the slave´s datasheet that they should come without interruption between them.
I can transfer data via SPI (using UCB1) when writing directly to the transmit register. The IE bit for UCB is not set. The uC is running smoothly, it handles the UART which is also running just fine (i.e. no lockup due to unhandled interrupt).
To get started, I had intended to write two bytes to the TX register using DMA channel 1. What I want is to trigger DMA every time the transmit buffer is empty until DMA1SZ transfers have taken place and then to call the DMA ISR. Unfortunately, this doesn´t work - I get neither SPI transmission nor is the ISR ever called.
Init:
DMACTL0 |= DMA1TSEL_23; // UCB1TXIFG as trigger
DMA1CTL = DMADT_4 + DMASRCINCR_3 + DMADSTBYTE + DMASRCBYTE + DMAIE + DMAEN;
__data16_write_addr((unsigned short) &DMA1SA,(unsigned long) spi_buffer_send);
__data16_write_addr((unsigned short) &DMA1DA,(unsigned long) UCB1TXBUF);
DMA1SZ = 2;
Transmit (called in the main loop):
spi_buffer_send[0] = 0x5A;
spi_buffer_send[1] = 0xA5;
if (!(DMA1CTL & DMAEN)) {
DMA1SZ = 2;
DMA1CTL |= DMAEN;
}
if (DMA1CTL & DMAIFG) {
rxtotal = DMA1CTL;
}
ISR:
#pragma vector=DMA_VECTOR
__interrupt void dma_isr (void) {
if (DMAIV & DMAIV_DMA0IFG) {
return;
}
if (DMAIV & DMAIV_DMA1IFG) {
return;
}
if (DMAIV & DMAIV_DMA2IFG) {
return;
}
}
Am I overlooking something, or is the MSP430 simply not able to do what I want?
I have already gone through Google and various code examples, but not come across something that actually helped. My last idea is to switch to level instead of edge triggering, then I am at the end of my wisdom.
Any help is appreciated. Thank you.
Max