AnsweredAssumed Answered

controlling UART ISR directly with (bypassing) MQX

Question asked by Michael David Gotesdyner on Oct 4, 2011
Latest reply on Sep 2, 2012 by crezyoz

 

I'm trying to configure a UART ISR.

I using MQX, but here I want to control the ISR directly.

The ISR doesn’t work when I start writing. (after sending one byte It doesn’t enter to the ISR )

Can You see if there is something missing in my configuration.

Michael David.

 

Here is my UART Configuration:

 

void Uart_InitUart(void)

{

      uint_16 ubd,temp0,temp1,brfa;

      uint_32 sysclk = BSP_SYSTEM_CLOCK, baud0 = 57600;

      //UART configuration

      SIM_SCGC4 |= (SIM_SCGC4_UART0_MASK);

     

      PORTA_PCR14 = PORT_PCR_MUX(3);      //TX 0

      PORTA_PCR15 = PORT_PCR_MUX(3);      //RX 0

     

      UART_C2_REG(UART0_BASE_PTR) &= ~(UART_C2_TE_MASK | UART_C2_RE_MASK);

      /* Configure the UART for 8-bit mode, no parity */

      /* We need all default settings, so entire register is cleared */

      UART_C1_REG(UART0_BASE_PTR) = 0;

      /* Calculate baud settings */

      ubd = (uint_16)((sysclk*1000)/(baud0 * 16));      

      /* Save off the current value of the UARTx_BDH except for the SBR */

      temp0 = UART_BDH_REG(UART0_BASE_PTR) & ~(UART_BDH_SBR(0x1F));

      UART_BDH_REG(UART0_BASE_PTR) = temp0 |  UART_BDH_SBR(((ubd & 0x1F00) >> 8));

      UART_BDL_REG(UART0_BASE_PTR) = (uint_8)(ubd & UART_BDL_SBR_MASK);

      /* Determine if a fractional divider is needed to get closer to the baud rate */

      brfa = (((sysclk*32000)/(baud0 * 16)) - (ubd * 32));

     

      /* Save off the current value of the UARTx_C4 register except for the BRFA */

      temp0 = UART_C4_REG(UART0_BASE_PTR) & ~(UART_C4_BRFA(0x1F));

      UART_C4_REG(UART0_BASE_PTR) = temp0 |  UART_C4_BRFA(brfa);

      /* Enable receiver */

      UART_C2_REG(UART0_BASE_PTR) |= ( UART_C2_RE_MASK | UART_C2_TE_MASK);

      // configure ISR  - UART 0 IRQ - 45

      NVICICPR1 |= (1<<13); //45 MOD 32

      NVICISER1 |= (1<<13);

      NVICIP45 = 0x30;        // priority 3. out of 15

     

      Isr_InitIsr(INT_UART0_RX_TX, Uart_RxTx0_Isr);

}

 

Here is the Isr_InitIsr function:

 

void Isr_InitIsr(_mqx_uint isr, void (_CODE_PTR_ isr_func)(pointer))

{

      MY_ISR_STRUCT_PTR  isr_ptr;

     

      isr_ptr = _mem_alloc_zero((_mem_size)sizeof(MY_ISR_STRUCT));

     

      isr_ptr->TICK_COUNT   = 0;

      isr_ptr->OLD_ISR_DATA = _int_get_isr_data(isr);

      isr_ptr->OLD_ISR      = _int_get_isr(isr);

     

      _int_install_isr(isr, isr_func, isr_ptr);

}

 

Outcomes