cancel
Showing results for 
Search instead for 
Did you mean: 

A question about STM32F767 USART Receiver timeout register

xshen
Associate II

Dear all,

I am using the usart2 of the STM32F767 to implement the Modbus function.

I used the Receiver timeout interrupt to detect if a piece of data is over.

However,sometimes a timeout interrupt had occurred. when data is still receive.

I set the timeout to 35 and the baud rate is 9600. Where is the wrong? I hope to get your help.

this is my code about usart init:

void uart2_init(u32 pclk1,u32 bound)

{

u32 temp;  

temp=(pclk1*1000000+bound/2)/bound;

PCF8574_Init();

RCC->AHB1ENR|=1<<0;  

GPIO_Set(GPIOA,PIN2|PIN3,GPIO_MODE_AF,GPIO_OTYPE_PP,GPIO_SPEED_50M,GPIO_PUPD_PU);

  GPIO_AF_Set(GPIOA,2,7);

GPIO_AF_Set(GPIOA,3,7);   

RCC->APB1ENR|=1<<17; 

RCC->APB1RSTR|=1<<17;  

RCC->APB1RSTR&=~(1<<17);      

  USART2->BRR=temp;

USART2->CR1=0;

USART2->CR1|=0<<28;

USART2->CR1|=0<<12;

USART2->CR1|=0<<15;

USART2->CR1|=1<<3;   

#if EN_USART2_RX  

USART2->CR1|=1<<2; 

    USART2->CR2 |= 1 << 23;

    USART2->CR1 |= 1 << 26;

    USART2->RTOR |= 35;

USART2->CR1|=1<<5;     

MY_NVIC_Init(3,3,USART2_IRQn,2);

#endif

USART2->CR1|=1<<0; 

RS485_TX_Set(0);

}​

And this is the phenomenon:

In the box that is circled below, there are fewer data received than the above. ​

0690X000008AsNgQAK.png

0 REPLIES 0