UART Receive Interrupt generated when data transmitted in ADSP-21489

Hi,

At attaches code is my project in CCES.

Code is written for UART Transmit and Receive through Interrupts (without DMA). 

When ever I send data on Transmit Line the Receive interrupt is also generated ? Why? 

/*****************************************************************************
 * UART_INTRs.c
 *****************************************************************************/

#include <sys/platform.h>
#include "adi_initialize.h"
#include "SRU.h"
#include <services/int/adi_int.h>
#include "sru.h"

typedef unsigned char uint8_t;
typedef unsigned short int  uint16_t;

volatile uint32_t UART_Status;
volatile uint32_t SPORT_Intr_ReadWord=0x0;
uint32_t DataReceived=0;
int TxCount=-1;
uint32_t TxData[100] = {5};

void Send_dataByte(uint32_t dat);
void delay_ms(uint32_t delayms);
void ISR_HandlersInstall(void);
void UartInit(void);
void UART_Tx_Data(int NumOfBytes);

int main(void)
{
	/* Initializes UART for Receive data through Rx-Interrupt (in PICR2 configured as P14) but Transmit through Polling */
	UartInit();

	/* Installs UART Handler */
	ISR_HandlersInstall();

	/* Begin adding your custom code here */
	while(1)
	{
		UART_Tx_Data(10);
		delay_ms(1000);
	}

}

void UART_Handler(void)
{
	int dummy;

	/* Below block of code shall be commented which is written for routing data as SPORT Data */
	UART_Status = *pUART0IIR;

	if( (UART_Status &4) == 4)
	{
		dummy = *pUART0RBR;
	}

	if( (UART_Status &2) == 2)
	{
		if(TxCount<0)
		{
			*pUART0TXCTL = 0;
			TxCount--;
		}
		else{
				*pUART0THR = SPORT_Intr_ReadWord++;
				TxCount--;
		}


	}

}	/* End of function : void UART_Handler(void) */

void UART_Tx_Data(int NumOfBytes)
{
	TxCount = NumOfBytes;
	SPORT_Intr_ReadWord=1;
	*pUART0THR = SPORT_Intr_ReadWord++;
	TxCount--;
	*pUART0TXCTL = UARTEN;
}


void Send_dataByte(uint32_t dat)
{
	while((*pUART0LSR & UARTTHRE) == 0);
	*pUART0THR = dat;
	while((*pUART0LSR & UARTTEMT) == 0);
}

void Delay(uint32_t delaycount)   /* This function is to provide  */
{
	uint32_t countDelay=0;

	for(countDelay=0;countDelay<delaycount;countDelay++)
	{
		asm("nop;");   /* To Spend one machine Cycle */
	}

}

void ISR_HandlersInstall(void)	/*Func in ISR_Handlers.c : ISRs are registered and then Interrupts are Enabled here... */
{
	adi_int_InstallHandler(ADI_CID_P13I,(ADI_INT_HANDLER_PTR )UART_Handler,0,true);
}

void delay_ms(uint32_t delayms)
{
	for(int ab=0; ab<delayms; ab++)
	{
		Delay(31000);
	}
}

void UartInit(void)
{

	volatile int temp;
	int picr2 = 0x00;

	/* Sets the UART0 receive interrupt to P13. */
	*pPICR2 &= ~(0x3E0);

	/* For I/O mode, both the transmit and receive interrupt can be programmed through
	 * the PICR register using the code select value for the UART receive interrupt (0x13 for UART0 interrupt) */
	*pPICR2 |= (0x13<<5);

	*pUART0LCR=0;

	(*pUART0IER) = UARTTBEIE|UARTRBFIE;		/* enable  UART RX & Tx interrupts */

		SRU2(UART0_TX_O,DPI_PB09_I);	/* UART TX signal is connected to DPI pin 9 */
		SRU2(HIGH,DPI_PBEN09_I);

		SRU2(DPI_PB10_O,UART0_RX_I);	/* connect the pin buffer output signal to the UART0 RX = DAI-Pin-10*/
		SRU2(LOW,DPI_PB10_I);
		SRU2(LOW,DPI_PBEN10_I);			/* disable DPI pin10 as input */

		(*pUART0LCR) = UARTDLAB;		/* enables access to divisor register to set baud rate */

		/* 0x000E for divisor value gives a baud rate of 921600 at 400 Mhz core clock */
		(*pUART0DLL) = 0x0E;
		(*pUART0DLH) = 0x00;

		(*pUART0LCR) = (UARTWLS8 );		//| UARTPEN | UARTSTB);   /* 8 bit word, odd parity, 2 stop bits */

		(*pUART0RXCTL) = UARTEN;        /* enable UART0 RX */
		(*pUART0TXCTL) = UARTEN;        /* enable UART0 TX */

}



Regards,

Muni. 

Parents
  • 0
    •  Analog Employees 
    on Sep 26, 2019 9:37 AM

    Hello,

    Can you please have a look at the example available in the ADSP-21489 Board support package(BSP) to check the DSP. Please download and install the board support package for ADSP-21489 in the below download.analog.com/.../ADI_ADSP-21489_EZKIT-Rel1.0.0.exe

    Once you installed, you can find the example code in the below path.
    [Installation directory]:\Analog Devices\ADSP-21489_EZKIT-Rel1.0.0\21489_EZ-Board\Examples\Power_On_Self_Test

    You can refer the ADSP-21489 UART example codes from above path.

    Regards,
    Lalitha.S

Reply
  • 0
    •  Analog Employees 
    on Sep 26, 2019 9:37 AM

    Hello,

    Can you please have a look at the example available in the ADSP-21489 Board support package(BSP) to check the DSP. Please download and install the board support package for ADSP-21489 in the below download.analog.com/.../ADI_ADSP-21489_EZKIT-Rel1.0.0.exe

    Once you installed, you can find the example code in the below path.
    [Installation directory]:\Analog Devices\ADSP-21489_EZKIT-Rel1.0.0\21489_EZ-Board\Examples\Power_On_Self_Test

    You can refer the ADSP-21489 UART example codes from above path.

    Regards,
    Lalitha.S

Children
No Data