AnsweredAssumed Answered

Need help regarding BF533 UART.

Question asked by mr_blackfin on Jul 23, 2013
Latest reply on Jul 24, 2013 by Andreas

Hello,

 

Hardware : BF533 EZ KIT

 

I am trying to transmit data on UART using DMA Interrupt based method and trying to receive using Non DMA Interrupt based method.

However, when I am not able to receive characters on the UART.

Is there any special care to be taken while running UART in mixed mode?

 

Following is my code:

 

/*********INCLUDES************************************************************************/

 

#include<cdefBF533.h>

#include<stdio.h>

#include<sys/exception.h>

 

/*********GLOBALS************************************************************************/

 

char tx_buff[15] = {'H','e','l','l','o',' ','W','o','r','l','d','!','!','!'};

short temp;

char c;

char received_data_from_UART[10];

int count = 0;

char rx_buff[10];

 

 

struct command_structure_UART

{

    unsigned char start_byte;   

    unsigned char transmitter_ID;

    unsigned char receiver_ID;   

    unsigned char command_response_code;

    short length_of_data;

    unsigned char check_sum;   

};

 

/*********FUNCTION DECLARATIONS************************************************************************/

void DMA_config_UART_TX(void);

EX_INTERRUPT_HANDLER(uart_transmit);

EX_INTERRUPT_HANDLER(uart_receive);

 

/******************************************************************************************

Function:     UART TX Interrupt Service Rouine.

 

Description: DMA based UART transmission

******************************************************************************************/

 

EX_INTERRUPT_HANDLER(uart_transmit)

{

    if(*pDMA7_IRQ_STATUS & 0x0008)

    {

    }

    else

    {

        *pDMA7_CONFIG = 0x0000;

    }

    *pDMA7_IRQ_STATUS |= 0x0001;

    //printf("\n Interrupt \n");

   

    temp = *pUART_IIR;

   

   

    asm("nop;");

}

 

 

/*****************************************************************************************

Function:      UART RX Interrupt Service Rouine.

 

Description: Read a character from RBR, and echo it to the UART.

             Reading RBR clears the interrupt request.

*****************************************************************************************/

 

EX_INTERRUPT_HANDLER(uart_receive)

{

   

    if(*pDMA6_IRQ_STATUS & 0x0001)

        *pDMA6_CONFIG = 0x0000;

    //printf("\n Interrupt \n");

    {

        c = *pUART_RBR;

        ssync();

 

        received_data_from_UART[count] = c;

        count++;

 

        printf("%c", c);   

        *pDMA6_IRQ_STATUS |= DMA_DONE;   

 

    }

}

 

 

/*****************************************************************************

Function    :    DMA_configMain

 

                 Configure the DMA for UART transmission

*****************************************************************************/

 

void DMA_config_UART_TX(void)

{

    *pDMA7_CONFIG = 0x0;

    *pDMA7_START_ADDR = tx_buff;

 

    *pDMA7_X_COUNT = 0x000F;        //Specify number of bytes to be transmitted

    *pDMA7_X_MODIFY = 0x0001;   

    *pDMA7_CONFIG = 0x0081;

    asm("ssync;");   

}

 

/*****************************************************************************

Function    :    Main

 

                 UART Transmission done using DMA Interrupt based method.

                 Whereas, UART Reception done using non DMA Interrupt based method.

*****************************************************************************/

 

void main()

{

    register_handler(ik_ivg10, uart_transmit);

    register_handler(ik_ivg10, uart_receive);

    *pSIC_IMASK = 0x8000 | 0x4000;

    asm("ssync;");

 

    DMA_config_UART_TX();

   

    //configure UART

    *pPLL_DIV = 0x06;

   

    *pUART_LCR = 0x0080;

 

    *pUART_DLH = 0x02;

    *pUART_DLL = 0x84;

 

    *pUART_LCR = 0x0000;

   

    *pUART_LCR = 0x0003;

   

    *pUART_IER = 0x0002 | 0x0001;        //Enabling Tx and Rx interrupt

   

    *pUART_GCTL = 0x0001;

   

    Init_PLL();

   

    asm("ssync;");

 

    asm("nop;");

 

    while(1)

    {

       

    }   

}

Outcomes