UART with DMA

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

UART with DMA

251 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gauchouizo on Tue Feb 28 05:27:39 MST 2012
Hi everybody

I'm trying to work with the UART with DMA. I'm working with LPCXpresso LPC1769 and the db from EA.
My DMA configuration:
    /* Habilitamos la interrupcion para la DMA */
    /* Inicializamos el control de la GPDMA */
    GPDMA_Init();
    /* Seteamos la interrupcion del GPDMA */
    // Apagamos la interrupcion
    NVIC_DisableIRQ (DMA_IRQn);
    // Modificamos la prioridad de la interrupcion
    // preemption = 1, sub-prioridad = 1
    NVIC_SetPriority(DMA_IRQn, ((0x01<<3)|0x01));

    // Configuramos el canal 0 del GPDMA para le recepcion de datos
    GPDMACfg.ChannelNum = 0;
    // Source memory
    GPDMACfg.SrcMemAddr = 0; //LPC_UART3->RBR;
    // Destination memory
    GPDMACfg.DstMemAddr = (uint32_t) &UART3Buffer;
    // Tamaño de los datos a transferir
    GPDMACfg.TransferSize = 10;//sizeof(UART3Buffer);
    // Ancho de la transferencia de datos
    GPDMACfg.TransferWidth = 0;
    // Tipo de transferencia
    GPDMACfg.TransferType = GPDMA_TRANSFERTYPE_P2M;
    // Fuente de coneccion
    GPDMACfg.SrcConn = GPDMA_CONN_UART3_Rx;
    // Linker List
    GPDMACfg.DMALLI = 0;
    // Configuracion con los parametros dados mas arriba
    GPDMA_Setup(&GPDMACfg);

    /* Reset terminal counter */
    Channel0_TC = 0;
    /* Reset Error counter */
    Channel0_Err = 0;

    // Enable interrupt for DMA
    NVIC_EnableIRQ (DMA_IRQn);

    // Enable GPDMA canal 0
    GPDMA_ChannelCmd(0, ENABLE);

The DMA works well, because I see the data that I sent before through the UART. I configured the Interrupt handler for the DMA:
void DMA_IRQHandler (void){
    vPrintString("Estoy en la Interrupcion DMA \n");
    if (GPDMA_IntGetStatus(GPDMA_STAT_INT, 0)){
        // Control del counter terminal status
        if (GPDMA_IntGetStatus(GPDMA_STAT_INTTC, 0)){
            // Clear terminate counter Interrupt pending
            GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 0);
            vPrintString("Terminate counter \n");
            Channel0_TC++;
        }
    }
    // Control del error terminal status
    if (GPDMA_IntGetStatus(GPDMA_STAT_INTERR, 0)){
        // Clear error counter Interrupt pending
        GPDMA_ClearIntPending (GPDMA_STATCLR_INTERR, 0);
        vPrintString("Error counter \n");
        Channel0_Err++;
    }
}// final ISR DMA


I've the following problem: when I start the programm and send data from the UART, it produces an interrupt and the programm goes into the interrupt handler. There I can reset the request from the DMA and can activate a semaforo or other thing to start my task, wich handles the data. The first time ocurs that, but no more and I don't understand why? Can help me anybody?
Other question: to read the DMA, which method is the best? Polling or interrupt? what about a variable data lenght? At the moment I'm using a fixed data lenght from 10 Bytes.
Maybe I missunderstand some thing, I've red the datasheet more times and I can't find the problem.
I'd appreciate some help.
Thank you
Pablo
0 Kudos
0 Replies