1716 views|3 replies

2870

Posts

4

Resources
The OP
 

Can anyone give me a serial port interrupt receiving program for STM32F03 without HAL library? [Copy link]

Can anyone give me a non-HAL library STM32F03 serial interrupt receiving program? Self-written or old program library is fine.

This post is from stm32/stm8

Latest reply

The LL library is as follows, see if you can use it. /** * @brief This function handles USART1 global interrupt. */ void USART1_IRQHandler(void) { /* USER CODE BEGIN USART1_IRQn 0 */ if (LL_USART_IsActiveFlag_RXNE(USART1)) { uart[0].rdBuff[uart[0].rdPtr++] = LL_USART_ReceiveData8(USART1); if (uart[0].rdEnabled==1) { if (uart[0].rdPtr==1 && uart[0].rdBuff[0]!=0xBB) uart[0].rdPtr=0; if (uart[0].rdPtr==2 && uart[0].rdBuff[1]!=0x66) uart[0].rdPtr=0; if (uart[0].rdPtr==3 && uart[0].rdBuff[2]!=0x66) uart[0].rdPtr=0; if (uart[0].rdPtr==4 && uart[0].rdBuff[3]!=0xBB) uart[0].rdPtr=0; } else uart[0].rdPtr=0; LL_USART_ClearFlag_RXNE(USART1); } else if (LL_USART_IsActiveFlag_IDLE(USART1)) { uart[0].rdEnded=1; LL_USART_ClearFlag_IDLE(USART1); } /* USER CODE END USART1_IRQn 0 */   Details Published on 2021-8-9 09:46
 

27

Posts

1

Resources
2
 

The LL library is as follows, see if you can use it.

/**
* @brief This function handles USART1 global interrupt.
*/
void USART1_IRQHandler(void)
{
/* USER CODE BEGIN USART1_IRQn 0 */
if (LL_USART_IsActiveFlag_RXNE(USART1)) {
uart[0].rdBuff[uart[0].rdPtr++] = LL_USART_ReceiveData8(USART1);
if (uart[0].rdEnabled==1) {
if (uart[0].rdPtr==1 && uart[0].rdBuff[0]!=0xBB) uart[0].rdPtr=0;
if (uart[0].rdPtr==2 && uart[0].rdBuff[1]!=0x66) uart[0].rdPtr=0;
if (uart[0].rdPtr==3 && uart[0].rdBuff[2]!=0x66) uart[0].rdPtr=0;
if (uart[0].rdPtr==4 && uart[0].rdBuff[3]!=0xBB) uart[0].rdPtr=0;
}
else uart[0].rdPtr=0;
LL_USART_ClearFlag_RXNE(USART1);
}
else if (LL_USART_IsActiveFlag_IDLE(USART1)) {
uart[0].rdEnded=1;
LL_USART_ClearFlag_IDLE(USART1);
}

/* USER CODE END USART1_IRQn 0 */

This post is from stm32/stm8

Comments

Thank you, this program cannot be used because my version does not have the routine of LL_USART_ClearFlag_RXNE library. Can you send me the source code of your LL_USART_ClearFlag_RXNE routine?  Details Published on 2021-8-9 10:00
 
 

2870

Posts

4

Resources
3
 
daemondong posted on 2021-8-9 09:46 The LL library is as follows, see if you can use it. /** * @brief This function handles USART1 global interrupt. ...

Thank you, this program cannot be used because my version does not have the routine of LL_USART_ClearFlag_RXNE library. Can you send me the source code of your LL_USART_ClearFlag_RXNE routine?

This post is from stm32/stm8
 
 

2870

Posts

4

Resources
4
 

Thank you for your answers. The problem is not due to these reasons, but the problem of calling array in the main loop. It has been solved now.

This post is from stm32/stm8
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list