[Nucleo G071 Review] Serial port 1 idle interrupt + DMA to achieve variable length reception[Copy link]
After two days and one night of exploration, I finally figured out the temperament of the DMA of the G0 series models, and I can carry out my next serial port variable length reception DEMO. The G0 series DMA has only one peripheral DMA1, which supports 7 channels. These 7 channels are also very user-friendly and can be arbitrarily assigned to any peripheral that supports DMA transmission, such as serial port, ADC, SPI interface, etc. I believe ST is learning from NXP's new RT1050 series. In other words, the RX receiving DMA channel of serial port 1 can be DMA1 channel 1, DMA1 channel 2, or even DMA1 channel 7. Since the LPUART1 peripheral on the board has been used for debugging and printing, I use serial port 1, namely PA9 PA10, to connect the external serial port module for experiments. First open CubeMX and configure serial port 1 and DMA. As shown in the figure, you can choose any one of the 7 channels. I chose DMA1 channel 1:
In the generated routine, there is a very important statement. Since the DMA of the G0 series does not specify a specific peripheral to use a specific channel, a DMAMUX controller is required to remap the channel. In layman's terms, it is to lock the channel. The relevant configuration is the Request member variable of DMA_InitTypeDef. It is this variable that troubled me all night last night, because the default Request variable is not specified in the routine generated by CubeMX: