1. 功能描述 该例程提供了一个DMA用法,用于在外围设备和RAM之间传输数据。 初始化CLOCK,GPIO,PERIPH,然后为I2C启用DMA,再启用DMA。 首先,DMA_CH6将I2C1_Tx_Buffer数据传输到I2C1的数据寄存器。 然后I2C1发送数据到I2C2。 最后,DMA_CH5将数据从I2C2的数据寄存器传输到I2C2_Rx_Buffer。 等待DMA传输完成,比较I2C1_Tx_Buffer和I2C2_Rx_Buffer之间的数据一致性,并将比较结果输出到串口。 2. 使用环境 软件开发环境: KEIL MDK-ARM V5.34.0.0 IAR EWARM 8.50.1 硬件环境: 基于评估板N32G430C8L7-STB V1.0开发 3. 使用说明 1.时钟源:HSE+PLL 2.主时钟:128MHz 3.DMA通道:DMA_CH5, DMA_CH6 4.I2C1配置: SCL --> PB8 50MHz, AF_OD SDA --> PB9 50MHz, AF_OD ADDR:0x30(7bit) 时钟:100K 5.I2C2配置: SCL --> PB10 50MHz, AF_OD SDA --> PB11 50MHz, AF_OD ADDR:0x30(7bit) 时钟:100K 6.USART1的配置: TX --> PA9 50MHz, AF_PP 波特率:115200 数据位:8位 停止位:1位 无校验 7.测试步骤和现象 A. 编译下载代码复位运行 B. 从串口查看打印的信息并验证结果 4. 注意事项 I2C总线必须配备一个外部上拉电阻,建议为2.2-4.7K 1. Function description This routine provides a DMA usage for transferring data between peripherals and RAM. Initialize CLOCK, GPIO, PERIPH, then enable DMA for I2C, then enable DMA. First, DMA_CH6 transfers I2C1_Tx_Buffer data to the data register of I2C1, And then I2C1 sends the data to I2C2. Finally, DMA_CH5 transfers data from the I2C2 data register to I2C2_Rx_Buffer. Wait for the DMA transfer to complete, Compare the data consistency between I2C1_Tx_Buffer and I2C2_Rx_Buffer and output the comparison result to the serial port 2. Use environment Software development environment: KEIL MDK-ARM V5.34.0.0 IAR EWARM 8.50.1 Hardware environment: Developed based on the evaluation board N32G430C8L7-STB V1.0 3. Instructions for use 1.Clock source: HSE+PLL 2.Master clock: 128MHz 3.DMA channels: DMA_CH5, DMA_CH6 4.I2C1 configuration: SCL --> PB8 50MHz, AF_OD SDA --> PB9 50MHz, AF_OD ADDR: 0x30(7bit) CLOCK: 100K 5.I2C2 configuration: SCL --> PB10 50MHz, AF_OD SDA --> PB11 50MHz, AF_OD ADDR: 0x30(7bit) CLOCK: 100K 6.USART1 configuration: TX --> PA9 50MHz, AF_PP Baud rate: 115200 Data bit: 8 bits Stop bit: 1bit No check 7.Test steps and phenomena A. Compile download code reset run B. View the printed information from the serial port and verify the result 4. Precautions The I2C bus must be equipped with an external pull-up resistor, which is recommended to be 2.2-4.7K