Hi, I am trying to get DMA1 to receive 10 characters without CPU intervention, over UART5, Kinetis K60:
I successfully managed to transfer 10 chars over UART5 using DMA0, no CPU intervention.
I post my UART DMA1 settings, I thing I have something wrong in it, or missing something (
| _DMA0_ISR, | | /* 0x10 0x00000040 - ivINT_DMA0 |
_DMA1_ISR, /* 0x10 0x00000044 - ivINT_DMA1
) in vectors.c
uint32_t UART5_RX_DMA1_init(uint8_t length_of_transfer)
{
/* Enable Clock gating for the DMA1 and DMA MUX */
// _bsp_edma_enable(1);// /* Enable DMAMUX clock */ <
SIM_SCGC6 |= SIM_SCGC6_DMAMUX_MASK;/// /* Enable DMA clock */ <
DMAMUX_CHCFG1 = (1<<7)|12; //Select UART5 RX as channel source
SIM_SCGC7 |= SIM_SCGC7_DMA_MASK;
//DMAMUX_CHCFG1 = (1 << 7 ) | 13;
DMA_CR = 0;
/////////////////////////////////////////////////////////////////////////////////////////////////
// DMAMUX_CHCFG1 = 0x00; //Disable DMA MUX channel first //Channel Configuration Register (DMAMUX_CHCFG0)
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// DMA_TCD1_SADDR = (uint32_t)0x400EB007; //Set source address UART5_D / UART5 data register used to receive data
DMA_TCD1_SADDR = (uint32_t)&UART5_D;
DMA_TCD1_DADDR = (uint32_t)&buffer_RX.buffer[0]; //Set destination
DMA_TCD1_NBYTES_MLNO = 1; //TCD Minor Byte Count (Minor Loop Disabled)
DMA_TCD1_ATTR = 0 ;// 8-bit transfer, closed model of // TCD Transfer Attributes: Source data transfer size
DMA_TCD1_SOFF = 1; //Sign-extended offset applied to the current source address to form the next-state value as each source read is completed.
DMA_TCD1_DOFF = 0; //Sign-extended offset applied to the current destination address to form the next-state value as each destination write is completed.
DMA_TCD1_SLAST = 0; //Adjustment value added to the source address at the completion of the major iteration count. This value
//can be applied to restore the source address to the initial value, or adjust the address to reference the next data structure.
DMA_TCD1_DLASTSGA = 0; // Destination last address adjustment or the memory address for the next transfer control descriptor to be loaded into this channel (scatter/gather).
/*
* If (TCDn_CSR[ESG] = 0) then
• Adjustment value added to the destination address at the completion of the major iteration count.
This value can apply to restore the destination address to the initial value or adjust the address to reference the next data structure
else
• This address points to the beginning of a 0-modulo-32-byte region containing the next transfer
control descriptor to be loaded into this channel. This channel reload is performed as the major
iteration count completes. The scatter/gather address must be 0-modulo-32-byte, else a
configuration error is reported.
*/
DMA_TCD1_CITER_ELINKNO = length_of_transfer;
DMA_TCD1_BITER_ELINKNO = length_of_transfer;
//DMAMUX_CHCFG1 = (1 << 7 ) | 12;
// DMAMUX_CHCFG1 = (1<<7)|12; //Select UART5 RX as channel source
/*
* Current Major Iteration Count
This 9-bit (ELINK = 1) or 15-bit (ELINK = 0) count represents the current major loop count for the channel.
It is decremented each time the minor loop is completed and updated in the transfer control descriptor memory. After the major iteration count is exhausted, the channel performs a number of operations (e.g.,
final source and destination address calculations), optionally generating an interrupt to signal channel completion before reloading the CITER field from the beginning iteration count (BITER) field.
NOTE: When the CITER field is initially loaded by software, it must be set to the same value as that contained in the BITER field.
NOTE: If the channel is configured to execute a single service request, the initial values of BITER and CITER should be 0x0001.
*/
// DMA_TCD1_CSR = 0;
DMA_TCD1_CSR = 1;
/*
* Channel Start
If this flag is set, the channel is requesting service. The eDMA hardware automatically clears this flag after
the channel begins execution.
0 The channel is not explicitly started
1 The channel is explicitly started via a software initiated service request
*/
// DMA_TCD1_CSR &= ~DMA_CSR_INTMAJOR_MASK;
DMA_TCD0_CSR |= DMA_CSR_INTMAJOR_MASK;
/*
* Enable an interrupt when major iteration count completes
If this flag is set, the channel generates an interrupt request by setting the appropriate bit in the INT when
the current major iteration count reaches zero.
0 The end-of-major loop interrupt is disabled
1 The end-of-major loop interrupt is enabled
*/
////////////////////////////////////////////////////////////////////////////////////
// DMAMUX_CHCFG1 |= DMAMUX_CHCFG_ENBL_MASK; //Enable the DMA MUX channel
///////////////////////////////////////////////////////////////////////////////////////////
DMA_TCD1_CSR |= DMA_CSR_DREQ_MASK;
/*
* Disable Request
If this flag is set, the eDMA hardware automatically clears the corresponding ERQ bit when the current
major iteration count reaches zero.
0 The channel’s ERQ bit is not affected
1 The channel’s ERQ bit is cleared when the major loop is complete
*/
// NVICISER0 |= (1 << 0) ;// enable interrupts NVICISERn = 1 << m, where N = 0/32, m = 0% 32
NVICISER0 |= (1 << 0) ;// enable interrupts NVICISERn = 1 << m, where N = 0/32, m = 0% 32
NVICICPR0 |= 1 << 0;
enable_irq(1);
DMA_ERQ |= (1 << 1) ; // Start
return MQX_OK;
}
Thank you,
Stel