EmbeddedRelated.com
Forums
Memfault State of IoT Report

msp430 dma spi problem

Started by el_777 December 24, 2006
I everybody, i have a big problem with the DMA and SPI modules, i working
with the msp4301611 and i use the module spi0 like a slave 3-wire, the
DMA
module is configured to the channel 0 for the RX0 and channel 1 for TX0,
the module spi1 is configure like master 3-wire.

The problem is that the UTXIFG0 is never clearing by the DMA, in
consequence never can transmit my data, but the weird is that for the RX
all work fine.

Then i copy and paste my code for the spi0 and DMA configuration to other
clean proyect without any modification, surprisingly the code working
perfectly.

Here is my code, i have the hope that somebody can help me, anythin
comment is always welcome.

This is the code that i use in the clean proyect:
/************************************************************/
//*******************************************************************************************************
// Inicializacion de DMA
//*******************************************************************************************************

void dma0_init(void)
{
// Setup triggers first
DMACTL0 = DMA0TSEL_3 + DMA1TSEL_4; // URXIFG0 UTXIFG0

DMA0SA = U0RXBUF_; // Direccion fuente = UART0 RX Buffer
DMA0DA = in_payload_; // Direccion destino = Memoria RAM @0x1100
payload
DMA0SZ = 483; // Transferencia de 483 bytes
DMA0CTL = DMADT_4 + DMADSTINCR_3 +DMASBDB + DMAEN + DMAIE; // Rep Sng,
Dest int, SrcByte-DestByte, DMA0 enable
///////////////////////////////////////////////
DMA1SA = out_payload_;
DMA1DA = U0TXBUF_;
DMA1SZ = 483;
DMA1CTL = DMADT_4 + DMASRCINCR_3 +DMASBDB + DMAEN + DMAIE; // Rep Sng,
Src int, SrcByte-DestByte, DMA0 enable

}

//*******************************************************************************************************
// Inicializacion de SPI
//*******************************************************************************************************
void spi0_init(void)
{
U0CTL = CHAR + SYNC + SWRST; // 8-bit data, modo SPI, SPI Slave,
Software reset
// U0CTL = SYNC + SWRST; // 7-bit data, modo SPI, SPI Slave, Software
reset
U0TCTL = CKPL + SSEL1 + STC; // Data on Falling Edge, SMCLK, 3-wire

U0BR0 = 0x02; // SPICLK set baud
U0BR1 = 0x0; // Don't need baud rate control register 2 - clear
it
U0MCTL = 0x0; // Don't need modulation control

P3SEL = 0x0E; // Selecciona la funcionalizadad SPI para los
perifericos
P3DIR = 0x0B; // Configura como salidas SIMO,CLK,CSn

ME1 |= USPIE0; // Modulo enable
U0CTL &= ~SWRST; // Remove RESET

}

#pragma vector=DACDMA_VECTOR
__interrupt void DMA(void)
{
if(DMA0CTL & DMAIFG)
{
DMA0CTL &= ~DMAIFG; //Borro la bandera
}

if(DMA1CTL & DMAIFG)
{ P2OUT &= ~0x01;
DMA1CTL &= ~DMAIFG; //Borro la bandera
P2OUT |= 0x01;
}
}


This is the code that i use for my aplication:
//*******************************************************************************************************
// Inicializacion de SPI
//*******************************************************************************************************
void spi_init(void)
{
//Configuracion del modulo SPI1 para el RF
U1CTL = CHAR + SYNC + MM + SWRST; // 8-bit data, modo SPI, SPI master,
Software reset
U1TCTL = CKPH + SSEL1 + STC; // Data on Rising Edge, SMCLK,
3-wire

U1BR0 = 0x02; // SPICLK set baud
U1BR1 = 0x0; // Don't need baud rate control register 2 - clear
it
U1MCTL = 0x0; // Don't need modulation control

P5SEL = 0x0E; // Selecciona la funcionalizadad SPI para los
perifericos
P5DIR = 0x0B; // Configura como salidas SIMO,CLK,CSn

ME2 |= USPIE1; // Modulo enable
U1CTL &= ~SWRST; // Remove RESET



U0CTL = CHAR + SYNC + SWRST; // 8-bit data, modo SPI, SPI Slave,
Software reset
// U0CTL = SYNC + SWRST; // 7-bit data, modo SPI, SPI Slave, Software
reset
U0TCTL = CKPL + SSEL1 + STC; // Data on Falling Edge, SMCLK, 3-wire

U0BR0 = 0x02; // SPICLK set baud
U0BR1 = 0x0; // Don't need baud rate control register 2 - clear
it
U0MCTL = 0x0; // Don't need modulation control

P3SEL = 0x0E; // Selecciona la funcionalizadad SPI para los
perifericos
P3DIR = 0x0B; // Configura como salidas SIMO,CLK,CSn

ME1 |= USPIE0; // Modulo enable
U0CTL &= ~SWRST; // Remove RESET
}
//*******************************************************************************************************
// Inicializacion de DMA
//*******************************************************************************************************
void dma_init(void)
{

// Setup triggers first
DMACTL0 = DMA0TSEL_3 + DMA1TSEL_4; // URXIFG0 UTXIFG0

DMA0SA = U0RXBUF_; // Direccion fuente = UART0 RX Buffer
DMA0DA = 0x14F9; // Direccion destino = Memoria RAM @ payload
DMA0SZ = 483; // Transferencia de 483 bytes
DMA0CTL = DMADT_4 + DMADSTINCR_3 +DMASBDB + DMAEN + DMAIE; // Rep Sng,
Dest int, SrcByte-DestByte, DMA0 enable
///////////////////////////////////////////////
DMA1SA = 0x1316;
DMA1DA = U0TXBUF_;
DMA1SZ = 483;
DMA1CTL = DMADT_4 + DMASRCINCR_3 +DMASBDB + DMAEN + DMAIE; // Rep Sng,
Src int, SrcByte-DestByte, DMA0 enable

}


#pragma vector=DACDMA_VECTOR
__interrupt void DMA(void)
{

if(DMA0CTL & DMAIFG)
{
DMA0CTL &= ~DMAIFG; //Borro la bandera
}

if(DMA1CTL & DMAIFG)
{ Data_Voice_out[0].Length = 0;
Data_Voice_out[1].Length = 0;
Data_Voice_out[2].Length = 0;
DMA1CTL &= ~DMAIFG; //Borro la bandera

}

}

Memfault State of IoT Report