AnsweredAssumed Answered

STM8L152C6T6 USART1 interrupt probelm

Question asked by verma.sushil on Jan 12, 2015
Hi , i am unable to transfer and receive data from usart1 using interrupt. I used polling method to transfer and receive data from usart1 and it is working OK. ( Tx and Rx are Shorted)
I am using STVD and Cosmic compiler to run the codes. My problem is that , with the below codes when i used enableinterrupt(); function , control is stuck somewhere and it not return to main loop .
So can you please tell us where is the problem. Also i am not able to run any interrupts too.


Codes are

main()
{
     disableInterrupts();     
     DeInitClock();
     DeInitGPIO();
          
     /* Select HSI as system clock source */
     #ifdef USE_HSI
          CLK_SYSCLKSourceConfig(CLK_SYSCLKSource_HSI);
          CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_1);     
          
      #else
          CLK_SYSCLKSourceSwitchCmd(ENABLE);
          /* Select 2MHz HSE as system clock source */
          CLK_SYSCLKSourceConfig(CLK_SYSCLKSource_HSE);
          CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_4);     
          CLK_HSICmd(DISABLE);
     #endif
     

UART_PORT_PIN_HIGH();

USART_Cmd(USART1,ENABLE);
 USART_DeInit(USART1); 
 CLK_PeripheralClockConfig(CLK_Peripheral_USART1, ENABLE);      
 USART_Init(USART1,BaudRate,USART_WordLength_8b,USART_StopBits_1,USART_Parity_No,USART_Mode_Tx|USART_Mode_Rx); 
 USART_ClockInit(USART1,USART_Clock_Enable,USART_CPOL_Low, USART_CPHA_1Edge,USART_LastBit_Disable); 
 USART_ReceiverWakeUpCmd(USART1,SET);
 USART_ITConfig(USART1,USART_IT_RXNE|USART_IT_TXE,ENABLE); 
 enableInterrupts();
USART_Tx_Buffer("t");
}

and in Interrupt handler file codes is below to write 1 in he lcd if interrupt executes.

  */
INTERRUPT_HANDLER(USART1_RX_IRQHandler,28)
{
/* In order to detect unexpected events during development,
   it is recommended to set a breakpoint on the following instruction.
*/
  //while (1);
     
     gotoxy_lcd(1,2);
  LCD_WRITE("1 ");     
     


}





Outcomes