AnsweredAssumed Answered

UART interrupt wake up without loosing data

Question asked by Eric Paljan on Sep 16, 2014
Latest reply on Jul 25, 2017 by Mark Butcher



I have a MK10DX128 VLH7 Microcontroller. The controller operates mostly in sleep mode. Now Im trying to kommunicate with my microcontroller. Sending data from the controller to the host works fine. But If I try to send data from host to my controller it dont work.

I use the interrupt wake up from rising edge on UART module. It wakes up, receive the first character without a problem but behind the first one it received only garbage.


I sendet "Hello".

And this is received:



My question is: Is there a possibility to receive data without loosing information when I use the transmitted datastream to wake up the controller?


My irq for the rising edge:


void UART_Status_irq()


    if(UART0_S2        &    UART_S2_RXEDGIF_MASK){                        // Rising edge interrupt

        UART0_S2        |=    UART_S2_RXEDGIF_MASK;                    // Clear interrupt flag

            int i=0;


            // Read command



                while(!(UART0_S1 & UART_S1_RDRF_MASK));

                UART_Receiver[i]        =    UART0_D;






My UART initialisation:


void UART_init(unsigned int baud,unsigned int uartclk_khz)                              // Initialise UART0


      Uint16 sbr,brfa;



      SIM_SCGC4         |=    SIM_SCGC4_UART0_MASK;                                     // Activate clock for UART

      SIM_SCGC5         |=    SIM_SCGC5_PORTB_MASK;                                     // Activate clock for PortC

      PORTB_PCR16       =     PORT_PCR_MUX(3);                                          // Set PortB 16 for UARC

      PORTB_PCR17       =     PORT_PCR_MUX(3);                                          // Set PortB 17 for UARC


      sbr               =     (Uint16)((uartclk_khz*1000)/(baud*16));

      UART0_BDH         =     (Uint8)((sbr & 0x1F00)>>8);                               // Write high word of baud rate into register

      UART0_BDL         =     (Uint8)(sbr & 0x00FF);                                    // Write low word of baud rate into register


      brfa              =     (((uartclk_khz*32000)/(baud*16))-(sbr*32));

      UART0_C4          =     (Uint8)(brfa & 0x001F);                                   // Write divider into register  

      UART0_C1          =     0;                                                        // 8-Bit-Mode,No parity


      UART0_PFIFO       |=    UART_PFIFO_TXFE_MASK                                      // Enable transmitter FIFO

                        |     UART_PFIFO_RXFE_MASK                                      // Enable receiver FIFO

                        |     UART_PFIFO_TXFIFOSIZE(2)                                  // Transmitter FIFO depth = 8 elements

                        |     UART_PFIFO_RXFIFOSIZE(2);                                 // Receiver FIFO depth = 8 elements


      UART0_BDH         |=    UART_BDH_RXEDGIE_MASK;                                    // Enable interrupts from an edge on RxD

      enable_irq(45);                                                                   // Enable interrupts from UART module

      NVICIP45          =     0x10;                                                     // Set Priority 1 to the UART module


      UART0_C2          |=    (UART_C2_TE_MASK | UART_C2_RE_MASK );                     // Enable receiver and transmitter


It would be nice when you can help me.