static void USART_Config(void)
{
/* USART configured as follow:
- BaudRate = 9600 baud
- Word Length = 8 Bits
- One Stop Bit
- No parity
- Receive and transmit enabled
- USART Clock disabled
*/
USART_Init(USART1, (uint32_t)9600, USART_WordLength_8b, USART_StopBits_1,
USART_Parity_No , (USART_Mode_TypeDef)(USART_Mode_Tx | USART_Mode_Rx));
/* Enable general interrupts */
enableInterrupts();
/* Enable the USART Receive interrupt: this interrupt is generated when the USART
receive data register is not empty */
USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
/* Enable the USART Transmit complete interrupt: this interrupt is generated when the USART
transmit Shift Register is empty */
USART_ITConfig(USART1, USART_IT_TC, ENABLE);
static void USART_Config(void)
{
/* USART configured as follow:
- BaudRate = 9600 baud
- Word Length = 8 Bits
- One Stop Bit
- No parity
- Receive and transmit enabled
- USART Clock disabled
*/
USART_Init(USART1, (uint32_t)9600, USART_WordLength_8b, USART_StopBits_1,
USART_Parity_No , (USART_Mode_TypeDef)(USART_Mode_Tx | USART_Mode_Rx));
/* Enable general interrupts */
enableInterrupts();
/* Enable the USART Receive interrupt: this interrupt is generated when the USART
receive data register is not empty */
USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
/* Enable the USART Transmit complete interrupt: this interrupt is generated when the USART
transmit Shift Register is empty */
USART_ITConfig(USART1, USART_IT_TC, ENABLE);
/* Enable USART */
USART_Cmd(USART1, ENABLE);
}//初始化
中断内实现数据发送 和接收
搞不清楚中断收发的原理吧,基本差不多了
中断发送数据,这里的数据是指我打包完的数据,存在数组里,发送给上位机,那么发送时是每进入一次中断,发送一个字节,直到发送完成,关闭发送中断,发送基本没有问题
现在在写接收的,目前是想把发送的数据回显在上位机上。