AnsweredAssumed Answered

Disabling Uart4 interrupt causes lockup

Question asked by carter.bob on Aug 27, 2017
Latest reply on Sep 10, 2017 by carter.bob

Hello Forum,


I have a function that I call to read data from Uart4. As there are a number of critical times that I need Uart4 interrupt disabled, I enable the interrupt on entry to the function and disable it after priocessing the uart data. However, I found that the
system locks up after executing the NVIC_DisableIRQ(USART3_8_IRQn) command. I've tried many things but I cannot seem to get it working. My code is as follows. Any help greatly appreciated.
 Kind Regards


void Enable_Usart4_Interrupts(void)


void Disable_Usart4_Interrupts(void)


void Usart4Init_RS485(void)
  USART_InitTypeDef USART_InitStructure;
  GPIO_InitTypeDef GPIO_InitStructure;
  NVIC_InitTypeDef NVIC_InitStructure;
  // Enable GPIOC and DMA clock
  // Enable USART4 APB clock
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART4, ENABLE);
  // Connect pin to Periph
  GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_0);   //  USART4 TX
  GPIO_PinAFConfig(GPIOC, GPIO_PinSource11, GPIO_AF_0);   //  USART4 RX
  // Configure pins as AF pushpull
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
  GPIO_Init(GPIOC, &GPIO_InitStructure);
  USART_InitStructure.USART_BaudRate = 9600;
  USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  USART_InitStructure.USART_StopBits = USART_StopBits_1;
  USART_InitStructure.USART_Parity = USART_Parity_No;
  USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;    
  USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
  USART_Init(USART4, &USART_InitStructure);
//  Enable the COM4 Receive interrupt: this interrupt is generated when the
//  COM4 receive data register is not empty


  // USART4 IRQ Channel configuration
  NVIC_InitStructure.NVIC_IRQChannel = USART3_8_IRQn;    


  // USART4 IRQ Channel priority     
  NVIC_InitStructure.NVIC_IRQChannelPriority = 0;    
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
 void USART3_8_IRQHandler(void)
uint8_t rx_byteby = 0;
USART_ClearITPendingBit(USART4, USART_IT_RXNE);      //Clear any pending uart interrupts bits        
  while (USART_GetITStatus(USART4, USART_IT_RXNE) != RESET) // Received characters modify string
        rx_byteby = USART_ReceiveData(USART4);
       rx_str[U4_rx_count++] = rx_byteby;                        


int Read_From_Uart4(void)
Enable_Usart4_Interrupts();   // Enable Usart4 interrupts for Uart4 data
// Receive and process UART4 data
//    .....

// ...

Disable_Usart4_Interrupts();  // Disable Usart4 interrupts