cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F07 USART3 Interrupt Enable? (한국어)

JLee.0.256
Associate

I am using the STM32F070CBT6 chip, and the compiler is using IAR 8.30.1.

Receive interrupt is not applied to USART3 enabled. We have confirmed that USART1 and USART2 are functioning normally.

The transmit function of USART3 is also possible, but only the receive interrupt is disabled.

When USART_IT_RXNE is disabled in UART_Config3 (), receive operation does not work and HardFault occurs. In other words, the CPU goes into Freeze state.

USART_ITConfig (USART3, USART_IT_RXNE, ENABLE);

-> USART_ITConfig (USART3, USART_IT_RXNE, DISABLE);

USART3 and USART4 use the same IRQ, is this related?

When I looked at the ST forum, two people questioned me about the same issue, but there was no solution.

https://community.st.com/s/question/0D50X00009XkZi7SAF/problem-with-the-interrupt-of-uart4-of-processor-stm32f072cbt6

I would like to know if it is my code is a problem or an H / W chip problem.

====================================================================================================

Korean :

저는 STM32F070CBT6 칩�?�, 컴파�?�러는 IAR 8.30.1 �?� 사용하고 있습니다.

USART3 사용함�? 수신 �?�터럽트가 걸리지 않습니다. USART1과 USART2 는 정�?작�?�함�?� 확�?�했습니다.

USART3 �?� 송신기능�?� 가능합니다만, 오로지 수신 �?�터럽트만 �?�작�?�지 않습니다.

UART_Config3() �?서 USART_IT_RXNE�?� Disable �?� 시키면 수신�?�작�?� �?�작하지 않고 HardFault 가 발�?합니다. 즉 CPU가 Freeze �?태�? 걸립니다.

USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);

-> USART_ITConfig(USART3, USART_IT_RXNE, DISABLE);

USART3 와 USART4 는 같�?� IRQ를 사용하는�?�, �?�것과 관련�?� 있나요?

ST �?�럼�? 찾아보니 저와 같�?� �?�슈때문�? 2명�?� �?��? 대해 질문�?� 올린�? 있는�?� 해결책�?� 나오지 않았�?�군요.

https://community.st.com/s/question/0D50X00009XkZi7SAF/problem-with-the-interrupt-of-uart4-of-processor-stm32f072cbt6

코딩 문제�?�지 H/W Chip 문제�?�지 알고 싶습니다.

====================================================================================================

void UART_Config3(void)

{

USART_InitTypeDef USART_InitStructure;

GPIO_InitTypeDef GPIO_InitStructure;

NVIC_InitTypeDef NVIC_InitStructure;

RCC_APB1PeriphClockCmd(RCC_APB1ENR_USART3EN, ENABLE);

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);

GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_4);

GPIO_PinAFConfig(GPIOB, GPIO_PinSource11, GPIO_AF_4);

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(GPIOB, &GPIO_InitStructure);

NVIC_InitStructure.NVIC_IRQChannel = USART3_4_IRQn;

NVIC_InitStructure.NVIC_IRQChannelPriority = 0x01;

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

NVIC_Init(&NVIC_InitStructure);

USART_InitStructure.USART_BaudRate = 9600; // 115200

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(USART3, &USART_InitStructure);

USART_ITConfig(USART3, USART_IT_RXNE, ENABLE); // 수신�?�터럽트를 받는 순간 뻗어버림

USART_Cmd(USART3, ENABLE);

}

void USART3_4_IRQHandler(void)

{

UINT8 ucRecv; // 임시 버�?�

// 받�?� 버�?� 그대로 뿌려줌.

  if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET)

  {

ucRecv = (UINT8)USART_ReceiveData(USART3);

USART_SendData(USART3, ucRecv);

}

}

1 REPLY 1

I'd suggest to use the debugger to inspect the USART register more deeply, confirming the bit settings, clocks, etc.

For local/auto variables make sure to clear the structures, and that you have an adequate stack.

USART_InitTypeDef USART_InitStructure = {0};

Getting a Hard Fault, track it down to the offending registers/instructions, it is not normal, and you best chance of understanding the failure mode.

Check for framing or noise errors on the USART, and clear them if detected, as the will block reception.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..