AT32F403A串口中断标志位使能函数usart_interrupt_enable

void usart_interrupt_enable(usart_type* usart_x, uint32_t usart_int, confirm_state new_state) 

 *          -USART_IDLE_INT:  idle interrupt

USART_IDLE_INT stands for USART Idle Line Interrupt. It is an interrupt generated by the USART (Universal Synchronous/Asynchronous Receiver/Transmitter) module of a microcontroller when the receiver detects an idle line condition.An idle line condition is detected when the receiver does not receive any new data on the serial communication line for a certain period of time. When this happens, the USART generates an interrupt to inform the microcontroller that a new message or data transmission may be starting.

The USART_IDLE_INT interrupt can be used by the microcontroller to implement a variety of communication protocols, such as detecting the start of a new message or waking up from a low power mode.

USART_IDLE_INT表示USART空闲线中断。它是由微控制器的USART(通用同步/异步接收器/发射器)模块在接收器检测到空闲线路条件时产生的中断。当接收器在一段时间内没有接收到串行通信线路上的任何新数据时,检测到空闲线路状况。当这种情况发生时,USART产生一个中断,通知微控制器可能正在开始新的消息或数据传输。

微控制器可以使用USART_IDLE_INT中断来实现各种通信协议,例如检测新消息的开始或从低功耗模式唤醒。

  *         - USART_RDBF_INT:  rdbf interrupt

USART_RDBF_INT stands for USART Receive Data Register Buffer Full Interrupt. It is an interrupt that occurs when the USART receives data and the receive data register buffer is full. This interrupt can be used to trigger a program to read and process the received data.

USART_RDBF_INT表示USART接收数据寄存器缓冲区完全中断。这是当USART接收数据并且接收数据寄存器缓冲区已满时发生的中断。这个中断可以用来触发程序读取和处理接收到的数据。
  *         - USART_TDC_INT:   tdc interrupt

USART_TDC_INT is a term that could refer to a specific interrupt that is related to USART (Universal Synchronous Asynchronous Receiver Transmitter) communication protocol and TDC (Time-to-Digital Converter) operation. In a microcontroller or microprocessor system, USART is a communication protocol used for serial communication between devices. TDC is a device that measures the time interval between two digital signals and converts it into a digital output in a very precise manner.

The USART_TDC_INT interrupt could be a software or hardware interrupt that triggers when there is a specific event related to the USART and TDC operation, such as the reception of data from a USART port or the completion of a TDC measurement. The handler function associated with this interrupt can perform specific tasks related to USART and TDC operation, such as transmitting or receiving data, or processing the TDC measurement output.

USART_TDC_INT是一个术语,可以指与USART(通用同步异步接收发送器)通信协议和TDC(时间到数字转换器)操作相关的特定中断。在微控制器或微处理器系统中,USART是一种用于设备之间串行通信的通信协议。TDC是一种测量两个数字信号之间的时间间隔并以非常精确的方式将其转换为数字输出的设备。

USART_TDC_INT中断可以是软件或硬件中断,当有与USART和TDC操作相关的特定事件时触发,例如从USART端口接收数据或完成TDC测量。与此中断相关的处理函数可以执行与USART和TDC操作相关的特定任务,例如发送或接收数据,或处理TDC测量输出。

  *         - USART_TDBE_INT:  tdbe interrupt

USART_TDBE_INT, or Transmit Data Buffer Empty Interrupt, is a type of interrupt that is generated when the transmit data buffer of a universal synchronous/asynchronous receiver-transmitter (USART) is empty and ready to receive new data. This interrupt is useful in situations where the data transmission is continuous, and the buffer needs to be refilled with new data as soon as it becomes available. When the USART_TDBE_INT is triggered, the CPU can interrupt the ongoing process and execute the data transfer instructions to refill the transmit buffer with fresh data. This interrupt helps in improving the communication performance and reducing the delay in data transmission.

USART_TDBE_INT,或传输数据缓冲区空中断,是一种中断类型,当通用同步/异步接收器-发射器(USART)的传输数据缓冲区为空并准备接收新数据时产生。这种中断在数据传输是连续的,并且缓冲区需要在可用时立即用新数据重新填充的情况下很有用。当USART_TDBE_INT被触发时,CPU可以中断正在进行的进程,并执行数据传输指令,用新数据重新填充传输缓冲区。这种中断有助于提高通信性能,减少数据传输的延迟。
  *         - USART_PERR_INT:  perr interrupt

USART_PERR_INT是一种中断类型,当在USART(通用同步异步接收发送器)通信中检测到奇偶校验错误时触发。USART是微控制器中的通信接口,允许在微控制器和外部设备之间传输数据。

奇偶校验是一种用于检测数据传输错误的方法。在奇偶校验中,一个额外的位,称为奇偶校验位,被添加到每个数据字节。选择校验位的值是为了保证数据字节中包含校验位的1的总数总是偶数或奇数。当接收到数据时,将检查奇偶校验位,以确保数据字节中的1的总数与期望的奇偶校验值匹配。如果不是,则检测到奇偶校验错误,表明数据传输损坏。

当在USART中检测到奇偶校验错误时,触发USART_PERR_INT中断。这个中断可以被编程来触发一个中断服务程序(ISR)来处理这个错误。然后,ISR可以采取适当的操作来处理错误,例如重新发送数据或通知用户错误。

  *         - USART_BF_INT:    break frame interrupt

USART BF stands for "USART Break Frame". The break frame interrupt is an interrupt requested when a break character is detected on the receive line. The break character is a low-level signal sent on the transmit line which lasts longer than a normal start bit and is used to signal various conditions, such as a line error or a reset signal. When the break frame is detected, the BF flag is set in the USART status register, and the USART generates a break interrupt request to the processor. The processor can then respond to the interrupt request by executing an interrupt service routine to handle the break condition. In summary, USART BF interrupt is an interrupt that is generated when a break frame is detected on the receive line.

USART BF代表“USART破帧”。中断帧中断是当接收线上检测到中断字符时请求的中断。中断字符是在传输线上发送的低电平信号,它比正常的起始位持续时间长,用于表示各种情况,例如线路错误或复位信号。

当检测到中断帧时,在USART状态寄存器中设置BF标志,USART向处理器发出中断中断请求。然后处理器可以通过执行中断服务例程来处理中断条件来响应中断请求。

总之,USART BF中断是当接收线上检测到中断帧时产生的中断。

  *         - USART_ERR_INT:   err interrupt

USART_ERR_INT refers to the error interrupt in a USART (Universal Synchronous/Asynchronous Receiver/Transmitter) peripheral. This interrupt is triggered when the USART encounters an error during data transmission or reception, such as a framing error, parity error, or overrun error. When the interrupt is fired, the microcontroller can handle the error by clearing the flag, resetting the USART, or taking other corrective actions. In summary, the USART_ERR_INT is an interrupt that allows the microcontroller to detect and correct errors that occur during communication through the USART peripheral.

USART_ERR_INT指USART(通用同步/异步接收/发送)外设中的错误中断。当USART在数据传输或接收过程中遇到错误(如帧错误、奇偶错误或溢出错误)时触发此中断。当中断被触发时,微控制器可以通过清除标志、重置USART或采取其他纠正措施来处理错误。

总之,USART_ERR_INT是一个中断,它允许微控制器检测和纠正通过USART外设通信期间发生的错误。

  *         - USART_CTSCF_INT: ctscf interrupt

USART_CTSCF_INT refers to the Clear to Send (CTS) change flag interrupt in a USART (Universal Synchronous/Asynchronous Receiver/Transmitter) communication interface. In USART communication, CTS is a hardware flow control signal that is used to control the flow of data from the transmitter to the receiver. When the CTS signal changes its state, for example from low to high, it can trigger an interrupt (USART_CTSCF_INT) to notify the receiver about the change in the CTS signal. This interrupt can be used to implement software flow control mechanisms in the USART interface.

USART_CTSCF_INT是指USART(通用同步/异步接收/发送)通信接口中的清除发送(CTS)更改标志中断。在USART通信中,CTS是一种硬件流控制信号,用于控制从发送端到接收端的数据流。当CTS信号改变其状态时,例如从低到高,它可以触发一个中断(USART_CTSCF_INT)来通知接收方CTS信号的变化。该中断可用于在USART接口中实现软件流控制机制。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
好的,下面是一个GD32F303通过DMA发送串口中断接收的RS485串口DMA函数的示例代码: ```c #include "gd32f30x.h" #define USART USART1 #define USART_DMA_CHANNEL DMA_CH5 #define USART_DMA_STREAM DMA0_STREAM5 #define BUFFER_SIZE 128 uint8_t tx_buffer[BUFFER_SIZE]; uint8_t rx_buffer[BUFFER_SIZE]; uint16_t rx_len = 0; void rs485_init(void) { rcu_periph_clock_enable(RCU_USART1); rcu_periph_clock_enable(RCU_AF); gpio_init(GPIOA, GPIO_MODE_AF_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_9); gpio_init(GPIOA, GPIO_MODE_AF_OD, GPIO_OSPEED_50MHZ, GPIO_PIN_10); usart_deinit(USART); usart_baudrate_set(USART, 9600); usart_parity_config(USART, USART_PM_NONE); usart_word_length_set(USART, USART_WL_8BIT); usart_stop_bit_set(USART, USART_STB_1BIT); usart_hardware_flow_rts_config(USART, USART_RTS_DISABLE); usart_hardware_flow_cts_config(USART, USART_CTS_DISABLE); usart_transmit_config(USART, USART_TRANSMIT_ENABLE); usart_receive_config(USART, USART_RECEIVE_ENABLE); usart_enable(USART); nvic_irq_enable(USART1_IRQn, 0, 0); } void rs485_dma_init(void) { rcu_periph_clock_enable(RCU_DMA0); dma_deinit(USART_DMA_STREAM); dma_parameter_struct dma_init_struct; dma_init_struct.direction = DMA_MEMORY_TO_PERIPHERAL; dma_init_struct.memory_addr = (uint32_t)tx_buffer; dma_init_struct.memory_inc = DMA_MEMORY_INC_ENABLE; dma_init_struct.memory_width = DMA_MEMORY_WIDTH_8BIT; dma_init_struct.periph_addr = (uint32_t)&USART_DATA(USART); dma_init_struct.periph_inc = DMA_PERIPH_INC_DISABLE; dma_init_struct.periph_width = DMA_PERIPHERAL_WIDTH_8BIT; dma_init_struct.priority = DMA_PRIORITY_HIGH; dma_init(USART_DMA_STREAM, dma_init_struct); dma_circulation_disable(USART_DMA_STREAM); dma_memory_to_memory_disable(USART_DMA_STREAM); dma_channel_subperipheral_select(USART_DMA_STREAM, DMA_SUBPERI0_USART1_TX); usart_dma_transmit_config(USART, USART_DMA_CHANNEL, USART_DENT_ENABLE); dma_interrupt_enable(USART_DMA_STREAM, DMA_INT_FTF); nvic_irq_enable(DMA0_Channel5_IRQn, 0, 0); } void rs485_send_dma(uint8_t *buffer, uint16_t len) { memcpy(tx_buffer, buffer, len); dma_transfer_number_config(USART_DMA_STREAM, len); dma_memory_address_config(USART_DMA_STREAM, (uint32_t)tx_buffer); dma_channel_enable(USART_DMA_STREAM); } void rs485_receive_dma(void) { rx_len = 0; dma_transfer_number_config(USART_DMA_STREAM, BUFFER_SIZE); dma_memory_address_config(USART_DMA_STREAM, (uint32_t)rx_buffer); dma_channel_enable(USART_DMA_STREAM); } void USART1_IRQHandler(void) { if (usart_interrupt_flag_get(USART, USART_INT_FLAG_RBNE)) { uint8_t data = usart_data_receive(USART); // 处理接收到的数据 if (rx_len < BUFFER_SIZE) { rx_buffer[rx_len++] = data; } } } void DMA0_Channel5_IRQHandler(void) { if (dma_interrupt_flag_get(DMA0, DMA_CH5, DMA_INT_FLAG_FTF)) { dma_interrupt_flag_clear(DMA0, DMA_CH5, DMA_INT_FLAG_FTF); dma_channel_disable(USART_DMA_STREAM); } } ``` 这个示例代码中,我们使用了DMA来发送和接收RS485串口数据。在初始化函数 `rs485_dma_init()` 中,我们配置了USART的DMA传输通道,并设置了DMA的参数。在发送函数 `rs485_send_dma()` 中,我们将要发送的数据拷贝到发送缓冲区,并启动DMA传输。在接收函数 `rs485_receive_dma()` 中,我们启动DMA接收。 同时,我们也实现了USART和DMA的中断处理函数 `USART1_IRQHandler()` 和 `DMA0_Channel5_IRQHandler()`,用于处理接收和发送完成的中断事件。 希望这个示例对你有帮助!如果有任何问题,请随时提问。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值