AnsweredAssumed Answered

uart interrupt problem

Question asked by m.vinothraj on Jul 6, 2012
Latest reply on Jul 9, 2012 by Andrew Neil
hi,
   i have problem in uart interrupt.i can able to read the particular character in  void USARTx_IRQHANDLER(void) in stm32f4xx_it.c .But i cant able to read the string in void USARTx_IRQHANDLER(void). Advance thank for  Your help!!!

MY CODE: (i need how to get the string in uart interrupt from other device.get single character is working perfectly)

void USARTx_IRQHANDLER(void)
{
  if(USART_GetITStatus(UART4, USART_IT_RXNE) != RESET)
  {
    /* Read one byte from the receive data register */
    //RxBuffer[RxCounter++] = (USART_ReceiveData(UART4) & 0x7F);
          uint8_t ab;
          uint32_t i;
          uint8_t *buff;
          
          //ab=(USART_ReceiveData(UART4) & 0x7F);
               
       /*for(i=0;i<3;i++)
     {
          
          //while(USART_GetFlagStatus(UART4, USART_FLAG_RXNE) == SET);             // != RESET)             == RESET)      while(USART_GetFlagStatus(UART4, USART_FLAG_RXNE) == SET);
          RxBuffer[i]=(USART_ReceiveData(UART4) & 0x7F);
          if(RxBuffer[i]=='a')
          
               
     } */
          
          
          RxBuffer[0]=(USART_ReceiveData(UART4) & 0x7F);
       RxBuffer[1]=(USART_ReceiveData(UART4) & 0x7F);
          RxBuffer[2]=(USART_ReceiveData(UART4) & 0x7F);
          buff = RxBuffer;
          
           if(buff== "abc")                                                  
          {
           if (Command_index1 == 1)
    {
      RepeatState1 = 0;
      // Switch to play command 
      Command_index1 = 0;
    }
          
    else if (Command_index1 == 0)
    {
      // Switch to record command 
               RepeatState1 = 0;
      // Switch to play command 
      Command_index1 = 0;
               
      XferCplt = 1;
     
    }
   // else
    //{
    //  RepeatState = 0;
      // Switch to play command 
    //  Command_index = 0; 
   // } 
          
          }
           
           
           /*
           if(ab== 'b')
          {
           if (Command_index2 == 1)
    {
      RepeatState2 = 0;
      // Switch to play command 
      Command_index2 = 0;
    }
          
    else if (Command_index2 == 0)
    {
      // Switch to record command 
               RepeatState2 = 0;
      // Switch to play command 
      Command_index2 = 0;
               
      XferCplt = 1;
      
    }
   // else
    //{
    //  RepeatState = 0;
      // Switch to play command 
    //  Command_index = 0; 
   // } 
        }
           
           if(ab== 'c')
          {
           if (Command_index3 == 1)
    {
      RepeatState3 = 0;
      // Switch to play command 
      Command_index3 = 0;
    }
          
    else if (Command_index3 == 0)
    {
      // Switch to record command 
               RepeatState3 = 0;
      // Switch to play command 
      Command_index3 = 0;
               
      XferCplt = 1;
      
    }
   // else
    //{
    //  RepeatState = 0;
      // Switch to play command 
    //  Command_index = 0; 
   // } 
        }
           
           if(ab== 'd')
          {
           if (Command_index4 == 1)
    {
      RepeatState4 = 0;
      // Switch to play command 
      Command_index4 = 0;
    }
          
    else if (Command_index4 == 0)
    {
      // Switch to record command 
               RepeatState4 = 0;
      // Switch to play command 
      Command_index4 = 0;
               
      XferCplt = 1;
      
    }
   // else
    //{
    //  RepeatState = 0;
      // Switch to play command 
    //  Command_index = 0; 
   // } 
        }
           
           if(ab== 'e')
          {
           if (Command_index5 == 1)
    {
      RepeatState5 = 0;
      // Switch to play command 
      Command_index5 = 0;
    }
          
    else if (Command_index2 == 0)
    {
      // Switch to record command 
               RepeatState5 = 0;
      // Switch to play command 
      Command_index5 = 0;
               
      XferCplt = 1;
      
    }
   // else
    //{
    //  RepeatState = 0;
      // Switch to play command 
    //  Command_index = 0; 
   // } 
        }
           
           if(ab== 'f')
          {
           if (Command_index6 == 1)
    {
      RepeatState6 = 0;
      // Switch to play command 
      Command_index6 = 0;
    }
          
    else if (Command_index6 == 0)
    {
      // Switch to record command 
               RepeatState6 = 0;
      // Switch to play command 
      Command_index6 = 0;
               
      XferCplt = 1;
      
    }
   // else
    //{
    //  RepeatState = 0;
      // Switch to play command 
    //  Command_index = 0; 
   // } 
        }
           
           if(ab== 'g')
          {
           if (Command_index7 == 1)
    {
      RepeatState7 = 0;
      // Switch to play command 
      Command_index7 = 0;
    }
          
    else if (Command_index7 == 0)
    {
      // Switch to record command 
               RepeatState7 = 0;
      // Switch to play command 
      Command_index7 = 0;
               
      XferCplt = 1;
      
    }
   // else
    //{
    //  RepeatState = 0;
      // Switch to play command 
    //  Command_index = 0; 
   // } 
        }
           
           if(ab== 'h')
          {
           if (Command_index8 == 1)
    {
      RepeatState8 = 0;
      // Switch to play command 
      Command_index8 = 0;
    }
          
    else if (Command_index8 == 0)
    {
      // Switch to record command 
               RepeatState8 = 0;
      // Switch to play command 
      Command_index8 = 0;
               
      XferCplt = 1;
      
    }
   // else
    //{
    //  RepeatState = 0;
      // Switch to play command 
    //  Command_index = 0; 
   // } 
        }
           
           if(ab== 'i')
          {
           if (Command_index9 == 1)
    {
      RepeatState9 = 0;
      // Switch to play command 
      Command_index9 = 0;
    }
          
    else if (Command_index9 == 0)
    {
      // Switch to record command 
               RepeatState9 = 0;
      // Switch to play command 
      Command_index9 = 0;
               
      XferCplt = 1;
      
    }
   // else
    //{
    //  RepeatState = 0;
      // Switch to play command 
    //  Command_index = 0; 
   // } 
        }
           
           if(ab== 'j')
          {
           if (Command_index10 == 1)
    {
      RepeatState10 = 0;
      // Switch to play command 
      Command_index10 = 0;
    }
          
    else if (Command_index10 == 0)
    {
      // Switch to record command 
               RepeatState10 = 0;
      // Switch to play command 
      Command_index10 = 0;
               
      XferCplt = 1;
      
    }
   // else
    //{
    //  RepeatState = 0;
      // Switch to play command 
    //  Command_index = 0; 
   // } 
        }
                
   // if(RxCounter == NbrOfDataToRead)
   // {
      // Disable the UART4 Receive interrupt 
    //  USART_ITConfig(UART4, USART_IT_RXNE, DISABLE);
    //}*/
  }


  if(USART_GetITStatus(UART4, USART_IT_TXE) != RESET)
  {   
    /* Write one byte to the transmit data register */
    USART_SendData(UART4, TxBuffer[TxCounter++]);
          
    if(TxCounter == NbrOfDataToTransfer)
    {
      /* Disable the UART4 Transmit interrupt */
      USART_ITConfig(UART4, USART_IT_TXE, DISABLE);
    }
  }
}


 

Outcomes