How to enable UART Interrupt in imx6q?

1

I am using I.MX6Q Sabre SD board. I am trying to build custom image with my own start script and ld script. The image is to be loaded with u-boot. I am trying to enable the UART receive interrupt for UART1. But it does not enter the Interrupt service routine. I am able to sent and receive data by polling. What is the basic initialisation step for enabling uart interrupt? I have initialised the uart as follows,

void UART1_init(void)
{
int tmp;
//*********** UART1 IOMUX****************//
* R32 (IOMUXC_BASE_ADDR+0x280) = 0x00000003; // ALT3 CSI0_DAT10 TxD
* R32 (IOMUXC_BASE_ADDR+0x284) = 0x00000003; // ALT3 CSI0_DAT11 RxD
* R32 (IOMUXC_BASE_ADDR+0x920) = 0x00000001; //UART1_UART_RX_DATA_SELECT_INPUT
tmp=(* R32 (CCM_BASE_ADDR+0x24)) & 0x0000003F ; //CSCDR1 uart_podf div by 1
* R32 (CCM_BASE_ADDR+0x24) = tmp; // UART refclk = 80MHz

// Enable UART1
// enable uart1, ignore RTS, wordsize 8bits, 1 stop bit, no parity
*(unsigned int*)(UART1_UCR2_1) = 0x01; // reset UART state machines 
*(unsigned int*)(UART1_UCR2_1) = 0x2006; // UCR2 = CTSC,TXEN,RXEN=1,reset
*(unsigned int*)(UART1_UCR1_1) = 0x0001; // UARTEN = 1,enable the clock
*(unsigned int*)(UART1_UCR2_1) |= IGNORE_RTS<<14; // configure IRTS bit
*(unsigned int*)(UART1_UCR2_1) |= WORD8<<5;
*(unsigned int*)(UART1_UCR2_1) |= STOP1<<6;
*(unsigned int*)(UART1_UCR3_1) |= 0x00000004; // set RXD_MUX_SEL bit
*(unsigned int*)(UART1_UCR1_1) |= 0x0201; // recieve ready interput enable
// disable parity
*(unsigned int*)(UART1_UCR2_1) &= ~(0x00000100);
//SetRFDIV_to_div_by_1_UART1(); 
tmp = *(unsigned int*)(UART1_UFCR_1); // save UFCR to default value
*(unsigned int*)(UART1_UFCR_1) = 5<<7; // set RFDIV to div-by-1 or b101 
*(unsigned int*)(UART1_UFCR_1) |= tmp; // set other UFCR bits back to default
*(unsigned int*)(UART1_UBIR_1) = 0x4;
*(unsigned int*)(UART1_UBMR_1) = 0xD8;
*(unsigned int*)(UART1_UCR3_1) |= 0x00000040; 
*(unsigned int*)(UART1_UCR4_1) |= 0x00000081; 

/* RxTl =1 */
tmp = *(unsigned int*)(UART1_UFCR_1);
tmp = tmp & 0xffffffc0;
tmp = tmp | 0x00000001;
*(unsigned int*)(UART1_UFCR_1) = tmp;

/* Rf div */
tmp = *(unsigned int*)(UART1_UCR1_1);
tmp = tmp & 0xfffffcff;
tmp = tmp | 0x00000200;
*(unsigned int*)(UART1_UCR1_1) = tmp;
}

Am i missing some initialization steps for uart receive interrupt?

interrupt
uart
imx6
asked on Stack Overflow Oct 25, 2016 by Ajeesh • edited Oct 25, 2016 by Ajeesh

1 Answer

0

I found the problem. It wasn't in the UART initialization. I forgot to set the VBAR register(vector base address register), whose reset value is 0x00000000. I had linked my vector table at 0x0093ff80. After correctly setting the VBAR register, the UART interrupt is working fine with the above initializations. This is how i set VBAR,

ldr r6,=__ram_vectors_start
MCR p15,0,r6,c12,c0,0
MCR p15,0,r6,c12,c0,1
answered on Stack Overflow Oct 27, 2016 by Ajeesh • edited Oct 27, 2016 by Ajeesh

User contributions licensed under CC BY-SA 3.0