Home > other >  GD32VF103C - START plate serial port interrupt program, can realize send data, unable to receive, wh
GD32VF103C - START plate serial port interrupt program, can realize send data, unable to receive, wh

Time:09-25

The main function is as follows:

 # include "gd32vf103. H" 
# include "gd32vf103v_eval. H"
# include "systick. H"
#include

Extern uint32_t rxbuffer [];
Extern uint16_t rxcount;

Extern FlagStatus g_receive_complete;


Int main (void)
{
/* USART interrupt configuration */
Eclic_global_interrupt_enable ();
Eclic_priority_group_set (ECLIC_PRIGROUP_LEVEL3_PRIO1);
Eclic_irq_enable (USART0_IRQn, 1, 0);
Gd_eval_com_init (USART0);
Usart_interrupt_enable (USART0 USART_INT_RBNE);
While (1) {
//usart_interrupt_disable (USART0 USART_INT_RBNE);
If (g_receive_complete==SET) {
Rxcount=0;
G_receive_complete=RESET;
Delay_1ms (500);
Delay_1ms (500);
Printf (" % d \ n \ r ", rxbuffer [0]).
Printf (" % d \ n \ r ", rxbuffer [1]).
Printf (" % d \ n \ r ", rxbuffer [2]).
Printf (" % d \ n \ r ", rxbuffer [3]).
Printf (" % d \ n \ r ", rxbuffer [4]);
}
}

}

/* retarget the C library printf function to the USART */
Int _put_char int (ch)
{
Usart_data_transmit (USART0 (uint8_t), ch);
While (usart_flag_get (USART0 USART_FLAG_TBE)==RESET) {
}

return ch;
}



Interrupt handlers are as follows: (can enter the interrupt, it is not achieve the receiving)
 uint32_t rxbuffer [RX_BUF_SIZE]; 
__IO uint16_t rxcount=0;
__IO FlagStatus g_receive_complete=RESET;

Void USART0_IRQHandler (void)
{
If (RESET!=usart_interrupt_flag_get (USART0 USART_INT_FLAG_RBNE))
{
/* read one byte from the receive data register */
Rxbuffer [rxcount++]=(uint8_t) usart_data_receive (USART0);//

If (rxcount==RX_BUF_SIZE)
{
G_receive_complete=SET;
Usart_interrupt_disable (USART0 USART_INT_RBNE);

}

}
}


A serial port tool shows: only send, did not receive

CodePudding user response:

Receive enabled a did not open?

CodePudding user response:

You have sent the serial port, did not receive, basically proves nothing, just connect a serial port module can be sent, in accordance with the current phenomenon appears, your program does not enter the interrupt,

CodePudding user response:

Suggest you process with time delay, this will ensure complete data transmission is complete,
USART_SendData (USART1, USART_RX_BUF [t]);//send data to the serial port 1
While (USART_GetFlagStatus (USART1, USART_FLAG_TC)!=SET);//wait for sending end
USART_RX_STA=0; Clear sign,
  • Related