• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Microcontrollers » Stellaris® ARM® Microcontrollers » Stellaris® ARM® LM3S Microcontrollers Forum » UART rx interrupt problem
Share
Stellaris® ARM® Microcontrollers
  • Forum
Options
  • Subscribe via RSS
Helpful Stellaris® LM4F Series Links
  • LM4F Series
  • Stellaris PinMux Utility
  • Stellaris® LM4F120 LaunchPad
  • LM4F MCU Applications
  • LM4F MCU Video
  • ARM Cortex-M4F Whitepaper
  • Stellaris MCU Brochure
  • LM4F232 Eval Kit
  • Forums

    UART rx interrupt problem

    This question is not answered
    appala naidu g
    Posted by appala naidu g
    on Apr 29 2012 23:58 PM
    Prodigy130 points

    Hi all,

       i am using LM3S9B90 on Keil 4 platform with custom board. I am unable to get UART rx interrupt after i call UARTcharput(or UARTcharput NonBlocking) function which i am calling from a Uc OS II task.

    void StartTxmission( void  )
    {
    	U32 i,count;
    	unsigned long j,temp_reg_value;
    	Boolean temp;
    	U8 no_of_bytes_sent = 0;
    	
    	extern TxDataQueue_tag TxDataQParameters;
    	extern TxCntrlQueue_tag TxCntrlQParameters;
    	extern RxQueue_tag RxQParameters;
    	extern volatile Boolean TxRunning;
    	extern ProtoParams_tag ProtocolParameters;
    	extern U8 ErrorStatus;
    //	extern void __svc(1)  serial(U8 temp);
     //	tsk_lock();
        IntMasterDisable();
    	//__disable_irq();
    	
    
    	if( TxCntrlQParameters.CntrlBufIndex == 0 )
    	{
    		ProtocolParameters.SentFrameType = CONTROL;
    		//serial('f');
    		//UARTDisable(UART0_BASE);
    			
    		UARTCharPut(UartBaseTemp,TxCntrlQParameters.TxCntrlBuf[
    				TxCntrlQParameters.CntrlBufIndex]);
    //				printf("write success");
    //				if(temp==true)
    //				printf("write success");
    //				for(i=0;i<15000;i++);
    		//	while(1);
    		//	UARTEnable(UART0_BASE);
    		TxCntrlQParameters.CntrlBufIndex++;
    	}
    	else
    	{
    		ProtocolParameters.SentFrameType = DATA;
    //		UARTCharPut(UartBaseTemp, TxDataQParameters.
    //				TxDataBuf[TxDataQParameters.DataBufIndex] );
    //		
    //		TxDataQParameters.DataBufIndex++;
    				
    		for( ;
    			(TxDataQParameters.DataBufIndex <
    				TxDataQParameters.DataFrameLen); 
    //			(no_of_bytes_sent < MAX_NO_OF_BYTES_AT_A_TIME_TXMN);
    			no_of_bytes_sent++,
    			TxDataQParameters.DataBufIndex++ )
    		{
    			UARTCharPut(UartBaseTemp,TxDataQParameters.TxDataBuf[TxDataQParameters.DataBufIndex] );
    		}
    		TxDataQParameters.DataBufIndex = 1;
    	}
    	
    //	UARTTxIntModeSet(UARTn_BASE,UART_TXINT_MODE_EOT);
    //   	temp_reg_value = UARTIntStatus(UARTn_BASE, true );
    //	temp_reg_value = temp_reg_value | UART_INT_TX; 
    //	UARTIntEnable(UARTn_BASE,temp_reg_value);
    	//for(i=0;i<1000;i++);
    	//while(1){}
    //	HandleSerialTxmission();
    	//	tsk_unlock();
     	
    	IntMasterEnable();	
    
    //	__enable_irq();
    //	while(1){}	
    	//for(i=0;i<1000;i++);		 
    	return;
    }
    
    
    the above function(StartTxmission) i am calling from a task....after execution of this function processor is not taking any receive commands..
    kindly reply if anyone have an idea about it.
    
    
    Regards,
    Naidu.
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • TI Alex
      Posted by TI Alex
      on Apr 30 2012 10:30 AM
      Expert8210 points

      Naidu,

      Have you tried looking at the uC/OS-III text book? Chapter 9 "Interrupt Management" would be very helpful to read.

      Regards,

      Alex

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • appala naidu g
      Posted by appala naidu g
      on May 12 2012 01:29 AM
      Prodigy130 points

      Hi Alex,

         I've gone through interrupt managent in Ucos -III but that is of no help. now i've removed Ucos form my application.

       but same problem is coming. i've attached my code here. any advice will be highly appreciated.

      ---Initialisation of hardware interrupt
      void AFCinterruptInit(void)
      {
      // Configure the interrupt pin as an input and enable the pin to interrupt on
      // the falling edge (i.e. when the push button is pressed).

      GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_6); //AFC valid input
      GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_7); //AFC lock input
      // GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_6, GPIO_STRENGTH_8MA,GPIO_PIN_TYPE_STD_WPU);
      GPIOIntTypeSet(GPIO_PORTA_BASE, GPIO_PIN_6, GPIO_HIGH_LEVEL);
      // GPIOPinIntEnable(GPIO_PORTA_BASE, GPIO_PIN_6);
      // IntEnable(INT_GPIOA);
      }


      ----this is the interrupt handler for the hardware interrupt
      ----it sends the status to ECM processor after reading hardware pin
      void ISROfAFCValidInterrupt( void )
      {
      U8 temp_afc_data[2],err,i;
      extern U8 afc_lock;
      extern OS_EVENT *AFCLockAmpMailboxID;
      extern U8 CurrentAFCThreatID;
      extern U16 AFCValIntrCount;
      extern U16 IntrOccured;
      extern OS_EVENT *AfcLockSem;
      extern void SendAfcStatusToECMP(U8 afc_lock);
      void DisableAFCValidInterrupt( );
      void ReadAFCLock(U8 *result);

      GPIOPinIntClear(GPIO_PORTA_BASE,GPIO_PIN_6);
      IntMasterdisable();
      temp_afc_data[0] = CurrentAFCThreatID;
      ReadAFCLock(&temp_afc_data[1]);
      SendAfcStatusToECMP(temp_afc_data[1]);
      IntMasterEnble();
      }

      ---uart interrupt handler
      void ISROfSimSerialLinkInterrupt( void )
      {
      U8 temp_reg_value;
      extern Boolean NoECMProcessor;
      extern U32 UartBaseTemp;
      unsigned long ulStatus;
      extern void HandleSerialInterrupt( void );
      CPU_SR cpu_sr;

      // OSSchedLock();

      // OSIntEnter();
      IntMasterDisable();
      //#define UARTn_BASE UART1_BASE
      // IntDisable(INT_UART0);
      UartBaseTemp = UART1_BASE;
      NoECMProcessor = TRUE;
      HandleSerialInterrupt();
      IntMasterEnable();
      // OSIntExit();

      // OSSchedUnlock();
      }

      void ReadAFCLock( U8 *result )
      {
      *result = GPIOPinRead(GPIO_PORTA_BASE, GPIO_PIN_7); //AFC Lock pin Read
      *result = *result >> 7;
      }

      void SendAfcStatusToECMP(U8 afc_lock)
      {
      U8 threat_id;
      extern ThreatParameters_tag ThreatParameters[TotalNoOfThreats];
      extern void SendMessageToEP( U8 threat_id, EPMsg_tag ep_msg_no );

      threat_id = CurrentAFCThreatID;
      if( (ThreatParameters[threat_id].Valid == TRUE) &&
      (ThreatParameters[threat_id].AFCStatus != AFC_NOT_USED) &&
      (threat_id == CurrentAFCThreatID) )
      {

      switch(ThreatParameters[threat_id].AFCStatus)
      {
      case AFC_ACQUISITION : if(afc_lock == TRUE )
      {
      // afc_lock_occured_count++;
      ThreatParameters[threat_id].AFCStatus = AFC_TRACKING;
      SendMessageToEP( threat_id, AFC_STATUS );

      }
      break;

      case AFC_TRACKING : break;
      case AFC_TRACK_LOST_DUMMY :
      case AFC_TRACK_LOST :
      case AFC_EMISSION_LOST :
      if( (afc_lock) == TRUE )
      {
      ThreatParameters[threat_id].AFCStatus = AFC_TRACKING;
      SendMessageToEP( threat_id, AFC_STATUS );
      }
      break;
      }
      }
      }

      void SendMessageToEP( unsigned char threat_id, EPMsg_tag ep_msg_no )
      {
      unsigned char temp_ep_tx_msg_buf[50];

      extern ThreatParameters_tag ThreatParameters[TotalNoOfThreats];
      // extern SubsystemHealth_tag SubsystemHealth;
      extern void SendMessageThroLink( unsigned char *msg_ptr, unsigned char msg_length );
      extern void ConvertNumberToHexString( unsigned long number, unsigned char *string_ptr,
      unsigned char string_length,
      Boolean reverse_string );

      switch( ep_msg_no )
      {
      case AFC_STATUS :
      temp_ep_tx_msg_buf[0] = EP_AFC_STATUS_COMMAND_CODE;
      // if( threat_id < 5 )
      temp_ep_tx_msg_buf[1] = threat_id + '1';

      switch( ThreatParameters[threat_id].AFCStatus )
      {
      case AFC_ACQUISITION :
      temp_ep_tx_msg_buf[2] = EP_AFC_ACQUISITION_STATUS;
      break;

      case AFC_TRACKING :
      temp_ep_tx_msg_buf[2] = EP_AFC_TRACKING_STATUS;
      break;

      case AFC_TRACK_LOST :
      temp_ep_tx_msg_buf[2] = EP_AFC_TRACK_LOST_STATUS;
      break;

      case AFC_EMISSION_LOST :
      temp_ep_tx_msg_buf[2] = EP_AFC_EMISSION_LOST_STATUS;
      break;
      }
      SendMessageThroLink( temp_ep_tx_msg_buf, (unsigned char) 3 );
      break;

      // case SUBSYSTEM_HEALTH_STATUS :
      // temp_ep_tx_msg_buf[0] = EP_SUBSYSTEM_HEALTH_STATUS_MESSAGE;
      // ConvertNumberToHexString(
      // ((*((unsigned long *) &SubsystemHealth)) & 0xFFFFF),
      // &temp_ep_tx_msg_buf[1], (unsigned char) 8, FALSE );
      // SendMessageThroLink( temp_ep_tx_msg_buf, (unsigned char) 9 );
      // break;

      case TST_TXMN_FREQ_STATUS :
      temp_ep_tx_msg_buf[0] = EP_TST_TXMN_FREQ_STATUS_MESSAGE;
      if( threat_id < TotalNoOfMBJThreats )
      {
      temp_ep_tx_msg_buf[1] = 'S';
      }
      else
      {
      temp_ep_tx_msg_buf[1] = 'P';
      }
      temp_ep_tx_msg_buf[2] = '2';
      //SendMessageThroLink( temp_ep_tx_msg_buf, (unsigned char) 3 );
      break;
      }
      }


      void SendMessageThroLink( unsigned char *msg_ptr, unsigned char msg_length )
      {
      U16 temp_msg_buf_idx;
      U8 temp_idx;

      extern TxDataQueue_tag TxDataQParameters;
      extern MsgDataQueue_tag MessagesToBeSent;
      extern Boolean LinkDown;

      extern void PrepareDataFrame( void );

      // OSSchedLock(); ---modind

      /* scheduling is stopped so that task switching will
      not take place. So the corruption of Msg_buf is avoided*/

      temp_msg_buf_idx = MessagesToBeSent.MsgHeadIndex;
      MessagesToBeSent.MsgBuf[temp_msg_buf_idx] = msg_length;

      for( temp_idx=0; temp_idx < msg_length; ++temp_idx )
      {
      ++temp_msg_buf_idx;
      if( temp_msg_buf_idx >= TX_MSGS_BUF_SIZE )
      temp_msg_buf_idx = 0;

      MessagesToBeSent.MsgBuf[temp_msg_buf_idx]
      = msg_ptr[temp_idx];
      }

      ++temp_msg_buf_idx;
      if( temp_msg_buf_idx >= TX_MSGS_BUF_SIZE )
      temp_msg_buf_idx = 0;

      if( MessagesToBeSent.MsgTailIndex ==
      MessagesToBeSent.MsgHeadIndex )
      {
      MessagesToBeSent.MsgHeadIndex = temp_msg_buf_idx;
      if( TxDataQParameters.DataFrameLen == 0 )
      {
      // OSSchedUnlock(); ---modind

      if( LinkDown == FALSE )
      PrepareDataFrame( );
      }
      // else
      // OSSchedUnlock(); ---modind
      }
      else
      {
      MessagesToBeSent.MsgHeadIndex = temp_msg_buf_idx;
      // OSSchedUnlock();
      }

      return;
      }

      void PrepareDataFrame( void )
      {
      U16 temp_msg_idx;
      U8 temp_checksum, temp_tx_buf_idx, temp_idx, temp_msg_length,
      temp_char;

      extern TxDataQueue_tag TxDataQParameters;
      extern volatile Boolean TxRunning;
      extern ProtoParams_tag ProtocolParameters;
      extern MsgDataQueue_tag MessagesToBeSent;

      extern void StartTxmission( void );

      temp_checksum = 0;

      temp_msg_idx = MessagesToBeSent.MsgTailIndex;

      TxDataQParameters.TxDataBuf[0] = SOF_A;
      TxDataQParameters.TxDataBuf[1] = ProtocolParameters.SentFrameNo;
      temp_msg_length = MessagesToBeSent.MsgBuf[temp_msg_idx];
      TxDataQParameters.TxDataBuf[2] = temp_msg_length-1;

      for( temp_tx_buf_idx=3; temp_tx_buf_idx < temp_msg_length + 3;
      ++temp_tx_buf_idx )
      {
      ++temp_msg_idx;
      if( temp_msg_idx >= TX_MSGS_BUF_SIZE )
      temp_msg_idx = 0;
      TxDataQParameters.TxDataBuf[temp_tx_buf_idx]
      = MessagesToBeSent.MsgBuf[temp_msg_idx];
      temp_checksum = temp_checksum ^
      TxDataQParameters.TxDataBuf[temp_tx_buf_idx];
      }

      TxDataQParameters.TxDataBuf[temp_tx_buf_idx]
      = temp_checksum;
      temp_tx_buf_idx++;
      TxDataQParameters.TxDataBuf[temp_tx_buf_idx] = EOF_A;
      temp_tx_buf_idx++;

      ++temp_msg_idx;
      if( temp_msg_idx >= TX_MSGS_BUF_SIZE )
      temp_msg_idx = 0;

      ProtocolParameters.NoOfRetxmns = 0;

      TxDataQParameters.DataFrameLen = temp_tx_buf_idx;
      TxDataQParameters.DataBufIndex = 0;
      MessagesToBeSent.MsgTailIndex = temp_msg_idx;
      if( TxRunning == FALSE )
      {
      TxRunning = TRUE;
      StartTxmission( );
      }

      return;
      }


      void StartTxmission( void )
      {
      U32 i,count;
      unsigned long j,temp_reg_value;
      Boolean temp;
      U8 no_of_bytes_sent = 0;

      extern TxDataQueue_tag TxDataQParameters;
      extern TxCntrlQueue_tag TxCntrlQParameters;
      extern RxQueue_tag RxQParameters;
      extern volatile Boolean TxRunning;
      extern ProtoParams_tag ProtocolParameters;
      extern U8 ErrorStatus;
      // extern void __svc(1) serial(U8 temp);
      // tsk_lock();
      IntMasterDisable();
      //__disable_irq();

      if( TxCntrlQParameters.CntrlBufIndex == 0 )
      {
      ProtocolParameters.SentFrameType = CONTROL;
      //serial('f');
      //UARTDisable(UART0_BASE);

      UARTCharPut(UartBaseTemp,TxCntrlQParameters.TxCntrlBuf[
      TxCntrlQParameters.CntrlBufIndex]);
      // printf("write success");
      // if(temp==true)
      // printf("write success");
      // for(i=0;i<15000;i++);
      // while(1);
      // UARTEnable(UART0_BASE);
      TxCntrlQParameters.CntrlBufIndex++;
      }
      else
      {
      ProtocolParameters.SentFrameType = DATA;
      UARTCharPut(UartBaseTemp, TxDataQParameters.
      TxDataBuf[TxDataQParameters.DataBufIndex] );

      TxDataQParameters.DataBufIndex++;

      // for( ;
      // (TxDataQParameters.DataBufIndex <
      // TxDataQParameters.DataFrameLen);
      //// (no_of_bytes_sent < MAX_NO_OF_BYTES_AT_A_TIME_TXMN);
      // no_of_bytes_sent++,
      // TxDataQParameters.DataBufIndex++ )
      // {
      // UARTCharPut(UartBaseTemp,TxDataQParameters.TxDataBuf[TxDataQParameters.DataBufIndex] );
      // }
      // TxDataQParameters.DataBufIndex = 1;
      }

      // UARTTxIntModeSet(UARTn_BASE,UART_TXINT_MODE_EOT);
      // temp_reg_value = UARTIntStatus(UARTn_BASE, true );
      // temp_reg_value = temp_reg_value | UART_INT_TX;
      // UARTIntEnable(UARTn_BASE,temp_reg_value);
      //for(i=0;i<1000;i++);
      //while(1){}

      HandleSerialTxmission();
      // UARTDisable(UartBaseTemp);
      // UARTFIFODisable(UartBaseTemp) ;
      // UARTEnable(UartBaseTemp);
      // tsk_unlock();

      IntMasterEnable();

      // __enable_irq();
      // while(1){}
      //for(i=0;i<1000;i++);
      return;
      }

      void HandleSerialTxmission( void )
      {
      U8 no_of_bytes_sent = 0, temp_reg_value;
      U32 i;
      INT8U perr;
      INT8U *pname,terr1;
      BOOLEAN err,berr;
      extern U32 UartBaseTemp;
      extern ProtoParams_tag ProtocolParameters;
      extern TxDataQueue_tag TxDataQParameters;
      extern TxCntrlQueue_tag TxCntrlQParameters;
      extern OS_TMR *TxmnTOAlarmID;
      extern volatile Boolean TxRunning;
      extern void HandleProtocolTxmnTO(OS_TMR *ptmr, void *p_arg );
      if( ProtocolParameters.SentFrameType == CONTROL )
      {
      for( ;
      TxCntrlQParameters.CntrlBufIndex <
      TxCntrlQParameters.CntrlFrameLen;
      no_of_bytes_sent++,
      TxCntrlQParameters.CntrlBufIndex++ )
      {
      UARTCharPut(UartBaseTemp,
      TxCntrlQParameters.TxCntrlBuf[
      TxCntrlQParameters.CntrlBufIndex] );
      // for(i=0;i<15000;i++);
      }

      if( TxCntrlQParameters.CntrlBufIndex >=
      TxCntrlQParameters.CntrlFrameLen )
      {
      if( TxDataQParameters.DataBufIndex <
      TxDataQParameters.DataFrameLen )
      ProtocolParameters.SentFrameType = DATA;
      else
      {
      ProtocolParameters.SentFrameType = NONE;
      TxRunning = FALSE;
      }
      }
      }
      else
      {

      for( ;
      (TxDataQParameters.DataBufIndex <
      TxDataQParameters.DataFrameLen);
      // (no_of_bytes_sent < MAX_NO_OF_BYTES_AT_A_TIME_TXMN);
      no_of_bytes_sent++,
      TxDataQParameters.DataBufIndex++ )

      {
      UARTCharPut(UartBaseTemp,TxDataQParameters.TxDataBuf[TxDataQParameters.DataBufIndex] ); --------when i get this instruction executed iam unable to get rx interrupt
      //
      // Check the arguments.
      //
      // ASSERT(UARTBaseValid(UartBaseTemp));

      //
      // Wait until space is available.
      //
      // while(HWREG(UartBaseTemp + UART_O_FR) & UART_FR_TXFF)
      // {
      // }

      //
      // Send the char.
      //
      // HWREG(UartBaseTemp + UART_O_DR) = TxDataQParameters.TxDataBuf[TxDataQParameters.DataBufIndex];
      }


      // UARTDisable(UartBaseTemp);

      //// for(i=0;i<15000;i++);
      // UARTIntEnable(UartBaseTemp, UART_INT_RX | UART_INT_RT);
      // UARTEnable(UartBaseTemp);
      // UART1_CTL_R &= ~(UART_CTL_UARTEN | UART_CTL_TXE| UART_CTL_RXE);
      // UART1_CTL_R |= (UART_CTL_UARTEN | UART_CTL_RXE);


      // if( TxDataQParameters.DataBufIndex >= TxDataQParameters.DataFrameLen )
      // {
      // if( (ProtocolParameters.SentFrameType == DATA) )
      // {
      // berr = DeleteTimer(TxmnTOAlarmID);
      // TxmnTOAlarmID = OSTmrCreate(10,10,OS_TMR_OPT_ONE_SHOT,HandleProtocolTxmnTO,
      // (void *)0,pname,&perr);
      // err = OSTmrStart(TxmnTOAlarmID,&perr); //reset alarm logic
      // terr1 = OSTmrSignal();
      // ProtocolParameters.RetxmissionReqd = TRUE;
      // }
      // if( TxCntrlQParameters.CntrlBufIndex <
      // TxCntrlQParameters.CntrlFrameLen )
      // ProtocolParameters.SentFrameType = CONTROL;
      // else
      // {
      // ProtocolParameters.SentFrameType = NONE;
      // TxRunning = FALSE;
      // }
      // }
      }

      if( TxRunning == FALSE )
      {
      UARTIntClear(UartBaseTemp, UART_INT_TX);
      }

      return;
      }

      code flow is like here:

      after i got an hardware interrupt i will status to another processor.

      thanks,

      naidu.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    TI E2E™ Community
    • Support Forums
    • Blogs
    • Videos
    • Groups
    • Site Support & Feedback
    • Settings
    TI E2E™ Community Groups
    • TI University Program
    • Make the Switch
    • Microcontroller Projects
    • Motor Drive & Control
    Other Communities
    • Deyisupport
    • Designsomething.org
    • beagleboard.org
    • TI on Element 14
    • TI on TechXchangeSM
    Other Technical & Support Resources
    • WEBENCH® Design Center
    • Product Information Centers
    • Technical Documents
    • TI Design Network
    • TI Technical Articles
    • TI Training

    All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

    Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

    Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
    TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

    TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
    embedded processors, along with software, tools and the industry’s largest sales/support staff.

    © Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
    Trademarks | Privacy Policy | Terms of Use