Reply
Highlighted
Posts: 5
Registered: ‎04-13-2017

LEUART0 interrupt triggers only once

I'm using EFM32LG330 LEUART0. I was able to send and get chars without interrupts and now I want to upgrade my code. After succesfully getting one character LEUART breaks and doesn't send any more symbols even if I send them without interrupts. Maybe someone could point out my mistake.

 

My interrupt handler:

void LEUART0_IRQHandler(void){
	uint32_t leuartif = LEUART_IntGet(LEUART0);
	
	/* Check for RX data valid interrupt */
  if (leuartif & LEUART_IF_RXDATAV){
    /* Copy data into RX Buffer */
    uint8_t rxData = LEUART_Rx(LEUART0);
    GNSSRxBuf.data[GNSSRxBuf.wrI] = rxData;
    GNSSRxBuf.wrI             = (GNSSRxBuf.wrI + 1) % UART_BUFFER_SZ;
    GNSSRxBuf.pendingBytes++;

    /* Flag Rx overflow */
		if (GNSSRxBuf.pendingBytes > UART_BUFFER_SZ){
      GNSSRxBuf.overflow = true;
    }
		LEUART_IntClear(LEUART0, LEUART_IF_RXDATAV);
	}

    /* Check TX buffer level status */
  if (LEUART0->STATUS & LEUART_IF_TXBL){
    if (GNSSTxBuf.pendingBytes > 0){
      /* Transmit pending character */
      LEUART_Tx(LEUART0, GNSSTxBuf.data[GNSSTxBuf.rdI]);
      GNSSTxBuf.rdI = (GNSSTxBuf.rdI + 1) % UART_BUFFER_SZ;
      GNSSTxBuf.pendingBytes--;
    }

    /* Disable Tx interrupt if no more bytes in queue */
    if (GNSSTxBuf.pendingBytes == 0){
			LEUART_IntClear(LEUART0, LEUART_IF_TXBL);
    }
  }
}

Interrupt enable:

LEUART_IntClear(LEUART0, _LEUART_IF_MASK);
LEUART_IntEnable(LEUART0, LEUART_IF_RXDATAV);
NVIC_ClearPendingIRQ(LEUART0_IRQn);
NVIC_EnableIRQ(LEUART0_IRQn);

I doubt that mistake could be on functions of getting chars or strings because I use similar one for other UARTs succesfully