Uart receive interrupt and transmit polling in ADSP2148
Hi,
Attached is the CCES Project for UART Tx and Rx.
In this project UART-Rx is through Interrupt and UART-Tx is through Polling./*****************************************************************************
* UART_INTRs.c
*****************************************************************************/
#include <sys/platform.h>
#include "adi_initialize.h"
#include "UART_INTRs.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;
void Send_dataByte(uint32_t dat);
void delay_ms(uint32_t delayms);
void ISR_HandlersInstall(void);
void UartInit(void);
int main(void)
{
/**
* Initialize managed drivers and/or services that have been added to
* the project.
* @return zero on success
*/
adi_initComponents();
/* 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)
{
Send_dataByte(SPORT_Intr_ReadWord++); /* Transmit data on UART through polling */
delay_ms(100);
}
}
void UART_Handler(void)
{
/* Below block of code shall be commented which is written for routing data as SPORT Data */
UART_Status = *pUART0IIR;
if(UART_Status == 4)
{
/* INTERRUPT ARE COMING FOR EVERY DATA TRANSMITTED ON UART THROUGH POLLING FUNCTION MENTIONED ABOVE
* DESPITE NOT DATA IS SENT ON Rx-Line OF UART
* */
SPORT_Intr_ReadWord = *pUART0RBR;
}
else if(UART_Status == 2)
{
SPORT_Intr_ReadWord++;
}
} /* End of function : void UART_Handler(void) */
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_P14I,(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;
picr2 = *pPICR2; /* get PICR2 */
picr2 &= (~(0x1f<<10)); /* clear P14 bits */
picr2 |= (0x13<<10); /* set UART0RX */
(*pPICR2) = picr2; /* put it back */
*pUART0LCR=0;
(*pUART0IER) = UARTRBFIE; /* enable Only UART RX interrupt */
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 */
}
When ever I transmit data through polling receive interrupt also generated, why ?
Regards,
Muni.
Refer ez.analog.com/.../uart-receive-interrupt-generated-when-data-transmitted-in-adsp-21489
Please log in to reply.