Problem with DMA and UART Tx (MCF52233EVB)

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

Problem with DMA and UART Tx (MCF52233EVB)

1,287 Views
Gonza
Contributor I

Hello!

I'm using the MCF52233 evaluation board and i'm trying to use the TX of UART0 with the DMA0. After setting the registers values, i begin the DMA, but nothing is sended and I get the Error 0x11 in the MCF5282_DMA0_DSR register (bus error on Destination ). I saw for other posts in the forum but i didn´t find a solution. First i thought that the problem was the DMA, and tested it doing a memcopy, so the problem is between the UART and the DMA.

Thank you very much in advance for any help.

 

Gonzalo

PS: Sorry for my english Here is the main code

 

#include "support_common.h"

 

#define N 200                          // Bytes to Transfer

uint32 status;                           // For Debug

static unsigned char Source[N]; // Buffer

 

void main(void){

      int i;

      unsigned long int BaudRate=115200;

      uint16 ubgs= (uint16)((60000 * 1000)/(BaudRate * 32));

 

//-------INIT BUFFER

      for (i=0;i < N ; i++ )  Source[i]=65;            //Fill buffer with A

 

//------INIT UART 0

      MCF_GPIO_PUAPAR =MCF_GPIO_PUAPAR_URXD0_URXD0          //Enable RX pin

                                               | MCF_GPIO_PUAPAR_UTXD0_UTXD0;         //Enable TX pin

 

      MCF_UART_UCR(0) = MCF_UART_UCR_RESET_TX;                         //Reset Transmiter

      MCF_UART_UCR(0) = MCF_UART_UCR_RESET_RX;                        //Reset Receiver

      MCF_UART_UCR(0) = MCF_UART_UCR_RESET_MR;                        //Reset Mode Register

      MCF_UART_UMR(0) = MCF_UART_UMR_PM_NONE                           //Parity None

                                               | MCF_UART_UMR_BC_8;                                  // 8 bits

 

      MCF_UART_UMR(0) = MCF_UART_UMR_CM_NORMAL                      // Mode: Normal normal

                                              | MCF_UART_UMR_SB_STOP_BITS_1;            // 1 stopbit

 

      MCF_UART_UMR(0) = MCF_UART_UMR_SB(0x7);                                // Stop bit length = 1.000

 

      MCF_UART_UCSR(0)= MCF_UART_UCSR_TCS_SYS_CLK;             //Tx system clock

 

//BAUD RATE

      MCF_UART_UBG1(0) = (uint8)((ubgs & 0xFF00) >> 8);

      MCF_UART_UBG2(0) = (uint8)(ubgs & 0x00FF);

      MCF_UART_UCR(0) = MCF_UART_UCR_TX_ENABLED;                      //Enable Tx

 

//-------INIT DMA0

      MCF_SCM_DMAREQC=0x0000000C;                                   //Uart0 Tx to DMA0

      MCF_SCM_MPR   |= 0x04;                                                        //Enable DMA access

      MCF_SCM_GPACR0 |= 0x06;                                                  //read,write

      MCF_SCM_GPACR1 |= 0x06;                                                  //read,write

      MCF_SCM_PACR1  |= 0x06;                                                    //read, write for DMA

      MCF_SCM_PACR2  |= 0x60;                                                    //read, write for UART0

      MCF_SCM_RAMBAR |= MCF_SCM_RAMBAR_BDE;         //Back door enable

 

      MCF_DMA0_SAR = (volatile unsigned long) &Source[0]; //Set source

      MCF_DMA0_DAR =MCF_UART0_UTB;                                //Set destination

      MCF_DMA0_BCR = N;                                                             //Set de number of bits

 

      MCF_DMA0_DCR= MCF_DMA_DCR_EEXT |                      // External request On

                                          MCF_DMA_DCR_CS |                          // Cycle Steal On

                                          MCF_DMA_DCR_SINC |                      // Source Inc on

                                          MCF_DMA_DCR_SSIZE(0x01) |         // Source Size= 1 byte

                                          MCF_DMA_DCR_DSIZE(0x01) ;         // Dest Size=1 byte 

 

//----Start DMA

      MCF_DMA0_DCR |=MCF_DMA_DCR_START;

 

      while (MCF_DMA0_BCR & 0x02000000) {}                          // wait until dma finish

      status= MCF_DMA0_DSR;

      for( ; ; ) {}                                                                                      // do nothing

}

Labels (1)
0 Kudos
3 Replies

377 Views
mjbcswitzerland
Specialist V

Hi

 

Check that you have given peripherals the rights to access SRAM.

 

GPACR0 = SUP_USER_FULL_ACCESS;                                   // enable peripheral SRAM access

 

This is not needed by memcpy() type DMA, which needs just DMA permission plus the back-door address (when from/to FLASH).

 

Regards

 

Mark

 

www.uTasker.com

UART User's Guide

0 Kudos

377 Views
Gonza
Contributor I

First of all, thanks for your answer. I check this and I think is all right. the value of SUP_USER_FULL_ACCESS is 0x04 or 0x06 (this is from datasheet). So the code of the dma is:

 

MCF_SCM_DMAREQC=0x0000000C;

MCF_SCM_MPR  |= 0x04;

 

MCF_SCM_PACR1  = 0x06;                                 //read, write for DMA

MCF_SCM_PACR2  = 0x60;                                 //read, write for UART0

MCF_SCM_RAMBAR |= MCF_SCM_RAMBAR_BDE;

 

MCF_SCM_GPACR0 = 0x04;                                //read,write

MCF_SCM_GPACR1 = 0x04;                                 //read,write

 

and the Error in destination continues. 

 

Thanks again

Gonzalo

0 Kudos

377 Views
pslavkin
Contributor I
Hi Gonzalo, I'm Pablo, Have you solved your problem regarding DMA and UART?? I've exactly the same problem, on same board, and I'm still working on it without succes... Thanks in advance. Pablo.
0 Kudos