1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

MSP 430 DMA SPI problem

Discussion in 'Embedded' started by el_777, Dec 22, 2006.

  1. el_777

    el_777 Guest

    I everybody, i have a big problem with the DMA and SPI modules, i workin
    with the msp4301611 and i use the module spi0 like a slave 3-wire, the DM
    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, i
    consequence never can transmit my data, but the weird is that for the R
    all work fine.

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

    Here is my code, i have the hope that somebody can help me, anythi
    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 @0x110
    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, Softwar
    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 - clea
    it
    U0MCTL = 0x0; // Don't need modulation control

    P3SEL = 0x0E; // Selecciona la funcionalizadad SPI para lo
    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 - clea
    it
    U1MCTL = 0x0; // Don't need modulation control

    P5SEL = 0x0E; // Selecciona la funcionalizadad SPI para lo
    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, Softwar
    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

    }

    }
     
    el_777, Dec 22, 2006
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.