IMX6Q UART Interrupt

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

IMX6Q UART Interrupt

Jump to solution
1,164 Views
ajmalali
Contributor III

Hi,
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 recieve 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?

Labels (3)
Tags (2)
0 Kudos
1 Solution
685 Views
ajmalali
Contributor III

Hi,

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

Regards,
Ajmal

View solution in original post

3 Replies
685 Views
art
NXP Employee
NXP Employee

Oh, glad to hear that the problem is resolved :-)

Best Regards,

Artur

0 Kudos
685 Views
art
NXP Employee
NXP Employee

Have you properly initialized your UART interrupt handling routine and linked it to the correct interrupt vector? Please check.


Have a great day,
Artur

0 Kudos
686 Views
ajmalali
Contributor III

Hi,

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

Regards,
Ajmal