DMA memory to pin

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

DMA memory to pin

674 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by leluno on Tue Apr 15 01:37:23 MST 2014
i am trying AN10850 with codeRed/LPC1768. I do not understand, how pins are fixed to DMACCDestAddr
<code>
/* extensions for test DMA to FIOPIN */
int32_t dma_start_m2pin(int32_t ch,
                     void *src,
                     void *dest,
                     DMAC_LL_T *plli,
                     int32_t trans)
{
  int32_t sts = _ERROR;

  /* Verify that the selected channel has been allocated */
  if (dmadrv_dat.alloc_ch [ch] == TRUE)
  {
    /* Setup source and destination and clear LLI */
    dmadrv_dat.pdma->dma_chan [ch].src_addr = (uint32_t) src;
    dmadrv_dat.pdma->dma_chan [ch].dest_addr = (uint32_t) dest;
    //dmadrv_dat.pdma->dma_chan [ch].dest_addr = (uint32_t) 0x2009C054+3;

    dmadrv_dat.pdma->dma_chan [ch].lli = (uint32_t) plli;

    /* Use linked list control word if available */
    if (plli != NULL)
    {
      dmadrv_dat.pdma->dma_chan [ch].control = plli->next_ctrl;
    }
    else
    {
      /* Setup channel configuration */
      dmadrv_dat.pdma->dma_chan [ch].control =
          (DMAC_CHAN_INT_TC_EN |
          DMAC_CHAN_SRC_AUTOINC | DMAC_CHAN_DEST_WIDTH_8 |
          DMAC_CHAN_SRC_WIDTH_8 | DMAC_CHAN_DEST_BURST_1 |
          DMAC_CHAN_SRC_BURST_1 |
          DMAC_CHAN_TRANSFER_SIZE(trans));
    }

    /* Start channel transfer */
    dmadrv_dat.pdma->dma_chan [ch].config_ch =
      (DMAC_CHAN_FLOW_D_P2M | DMAC_CHAN_ENABLE | DMAC_SRC_PERIP(9) );

    sts = _NO_ERROR;
  }

  return sts;
}



...  
/* Use DMA to copy the data  PIN2/2-6 */
  dma_start_m2pin(dmach, (void *)(MEMSTART_U),(void *)(&(LPC_GPIO2->FIOPIN)), NULL, MEMSIZE);
//pin 3/25
//  dma_start_m2pin(dmach, (void *)(MEMSTART_U),(void *)(&(LPC_GPIO3->FIOPIN)), NULL, MEMSIZE);
...</code>

&(LPC_GPIO2->FIOPIN) is a 32bit value. wehre is the mcu told to choose the special Pins 2-6 from GPIO2?

How can i change DMACCDestAddr  to GPIO3.25?

Labels (1)
0 Kudos
7 Replies

565 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by leluno on Wed Apr 30 00:47:56 MST 2014
with this code its working exactly as it should:

#define DMA_CHAN_IE_ITC_EN 0xC001
 
LPC_GPDMACH0->DMACCConfig =(0
  | DMA_CHAN_IE_ITC_EN
//  | DMAC_CHAN_FLOW_D_M2M
  | DMAC_CHAN_FLOW_D_M2P
//  | DMAC_CHAN_FLOW_D_P2M
//  | DMAC_SRC_PERIP(DMA_REQUEST_SSP0_TX)
//  | DMAC_SRC_PERIP(9)
//  | DMAC_SRC_PERIP(DMA_REQUEST_SSP0_RX)
  | DMAC_DEST_PERIP(DMA_REQUEST_SSP0_TX)
//  | DMAC_DEST_PERIP(DMA_REQUEST_SSP0_RX)
  );
0 Kudos

565 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by leluno on Tue Apr 29 13:59:42 MST 2014
another question:
can i make a M2M-Transfer from AHB to SSP0DR or SOSPDR?
0 Kudos

565 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by leluno on Tue Apr 29 13:54:20 MST 2014
thanks for answering

I am trying to send data by dma from SSP0 to a spi-lcd. It works with this code:
//+++++++++++++
//SSP0Init();
//DMA_Init();
LPC_SC->DMAREQSEL = SC_DMASEL_timer0_MATCH1_notUART0rx;//i.V.m. DMAC_SRC_PERIP(9)LPC_GPDMACH0->DMACCConfig
LPC_SC->PCONP |= (1<<29);//Enable clock to DMA controller
LPC_GPDMA->DMACConfig=DMAC_CTRL_ENABLE;

//DMAChannel_Init(0,M2P);
  //Ch0 set for M2P transfer from mempry to peripheral/
  LPC_GPDMACH0->DMACCSrcAddr = AHB_BANK0;
  LPC_GPDMACH0->DMACCDestAddr =  &(SSP0DR);
  LPC_GPDMACH0->DMACCControl =(0
|DMAC_CHAN_INT_TC_EN
|DMAC_CHAN_SRC_AUTOINC
|DMAC_CHAN_SRC_WIDTH_8
|DMAC_CHAN_SRC_BURST_1
// |DMAC_CHAN_DEST_AUTOINC
|DMAC_CHAN_DEST_WIDTH_8
|DMAC_CHAN_DEST_BURST_1
|DMAC_CHAN_TRANSFER_SIZE(640)
);

  LPC_GPDMACH0->DMACCConfig |=(0
| DMAC_CHAN_ENABLE
//  | DMAC_CHAN_FLOW_D_M2P
  | DMAC_CHAN_FLOW_D_P2M
//  | DMAC_SRC_PERIP(DMA_REQUEST_SSP0_TX)
//  | DMAC_SRC_PERIP(9)
  | DMAC_SRC_PERIP(DMA_REQUEST_SSP0_RX)
//  | DMAC_DEST_PERIP(DMA_REQUEST_SSP0_TX)
//  | DMAC_DEST_PERIP(DMA_REQUEST_SSP0_RX)
  );

  SSP0DMACR = 0x01<<0;//176x
//-------------
Questions:
Data are in memory SSP0 is periphal. Why works P2M but not M2P?

I want to send Data with SSPO. Why is RX-request and not TX-request?

Transfer size is 640. This should be 320 16-bit-Pixels = 1 line on lcd. The transfer is only less than a half line. Why?



0 Kudos

565 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Pacman on Mon Apr 21 22:50:37 MST 2014
You can set up a DMA "transfer completed" interrupt.

Regarding the "pin 9" question: it's not pin 9, it's bit 9; there's no pins in the DMACSoftSReq register.

To explain a little better, take a look at section 31.4.2.3 in UM10360 (table 543), you will see the bits and the DMA connection.
You should especially look in the "(DMACSREQ)" column.

Regarding your DMAREQSEL question: In this register, you choose the source for DMA request bit (see table 559).
Eg. If you want bit 14 to trigger on a UART3 RX event, clear bit 6. If you want bit 14 to trigger on a Timer 3 match1 event, set bit 6.
When you program your DMA-channel, you select a DMA request for this channel (see table 564), and you can choose for instance to trigger on the source peripheral and set this value to 14, which means you would trigger on the bit you selected above.

Now go back to section 31.4.2.3 and look at table 543. Flip to section 31.5.15 and look again on table 559.
Go back again to section 31.4.2.3 and look at table 543. -See the connection ? (it's the function of the highest 8 bits in the DMAREQSEL you're changing; the first 8 are fixed and cannot be changed).

You can also choose not to trigger, but instead start the transfer manually, by setting the channel enable bit.

If you want to synchronize to the peripheral, you need to clear the corresponding bit in the DMACSync register.
Normally it's cleared at start-up, but it's a good idea to clear the bit explicitly in your code.
0 Kudos

565 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by leluno on Thu Apr 17 05:06:53 MST 2014
Pin9 from DMACSoftSReq must be set:

if (!(pinVAL(2,11))) {
LPC_GPDMA->DMACSoftSReq=(1<<9);
_delay_ms(200);
}

Why is it Pin9?


When DMA-job has ended, how can i reset to restart?
0 Kudos

565 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by leluno on Thu Apr 17 00:21:25 MST 2014
I now wont to change from timer  to switch as trigger. Instead of the timer one single dma-transfer shall be startet by a switch pin==0.

How to do this?

Writing per software in DMACSoftSingleRequest?


The DMAREQSEL ist to choose between different uarts and timers. There are 8 bits. If all are set to zero, does that mean, all 8 different uart-possibilities are choosen?

How than to deselect all uarts and timers?
0 Kudos

565 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by leluno on Tue Apr 15 04:57:00 MST 2014
problem solved.
its a 32bit transfer. you cannot choose single pins. You only can reduce with transfer-size.
0 Kudos