1, Problems and phenomena:
1. STM32F103VET6 was used in the company's products before, and GD32F103VET6 was selected to replace the chip when the chip price increased and it could not be bought at a high price. Before, colleagues directly burned the ST program into GD and ran at once. I haven't found any problems in a short time. After the stage, we found that sometimes the device cannot read the ICCID of the SIM card and the IMEI of the wireless communication module completely. After I received it, I summarized it according to the netizens GD32E103/F303 series replace STM32F103 And Introduction to porting STM32 to GD32 Modifications have been made where necessary. These problems can be solved by appropriately extending the software delay (for and while).
2. Recently, we found that the value of MCU internal temperature sensor read by us is incorrect. The conversion is always - 400 to - 407. We use 5 ADC, 3 external and 2 internal (one internal temperature sensor and one internal reference voltage). The data is read and transmitted in the form of ADC+DMA. Through debugging and tracking, it is found that the reading value is normal only when the power supply of the burner is 3.3V. However, when our external power is supplied, the ADC 16 channel acquisition immediately becomes 0XFFF(4095), and the other 4 channels are normal under any circumstances.
2, Thinking and solving
1. Encounter ADC. The first step for me to be lazy is to start looking for experience online. The problems I encountered may have been encountered by the majority of netizens before. I found many posts and had a lot of experience. GD32F130 multi-channel ADC sampling (based on DMA mode) And A comment on adc of gd32f103 Wait, many articles. But my problem is still unresolved.
2. Use your own brain. This problem is either ADC read error or DMA transfer error. Then readjust the program and do experimental analysis.
3. Test with the simplest DEMO and read directly with ADC. At the beginning, the ST library is used, and the configuration reading is still the same trend. Only read the internal temperature sensor. It is still the same trend (only 3.3V power supply, reading is normal, when our external power supply immediately 0XFFF). Is it the power problem? Check it. But. Look at Article 4.
4. Our previous version of the program is easy to use. Reading is normal in any case. That's a little silly. Then I'd better see the light one. Program comparison. ADC configuration part, DMA configuration part. all one to. The same is true for the part of ADC acquisition call. Add delay, configure DMA first, and then turn on ADC, etc. No, No. The whole function of ADC part is simply not directly, and the main function is directly copied and replaced. Still not.... Depressed to death.
5. Contact FAE of GD. Gave GD the official DEMO. Then use GD library, Gd DEMO (ADC to read internal temperature sensor). The same trend. As long as my equipment is powered on, No. The 3.3V power supply commissioning of the separate burner is OK.
6. The FAE of GD asks whether our ad port is connected to high voltage, such as 5V. I consulted the hardware engineer and said no. FAE said that some customers received 5V before, and the ADC acquisition was inaccurate. But my other 4-way AD acquisition is accurate. I don't think it's connected to high voltage, either.
7. But the problem hasn't been solved. Then check the power all the way first. Connect the DC power supply directly to 1117. Alas, it still can't. this is a little magical. Direct connection of 3.3V is good. It depends on whether there is a problem with 5V. Look at the schematic diagram and find a hardware engineer. It seems that there is 5V over LIN.
LIN_TX_CPU pin, one quantity voltage 3.7V.
In the official Manual:
• ADC power supply requirements: 2.6V to 3.6V, and the general power supply voltage is 3.3V.
Next: I just take off R23. Ah, there is hope. All right. It's really connected to high voltage... Is the problem solved?
Why 3.7V? The leader said that VDD of 3.3V + diode voltage drop of about 0.4 has a clamping function. Hardware knowledge is a little poor. It's over. Keep checking.
8. Then why is our previous version of the program OK. There is really a gap in the procedure. What's the difference?
In the old version of the program, the device works, and the voltage of a 25PIN is 3.3V
In the new version of the program, the device works, and the voltage of a 25PIN is 3.7V.
That is, the external input voltage can be adjusted to 3.3V through the program?
9. In the old version, 25 pins were configured in the main function, and the LIN function was used before.
Moreover, such configuration is in while. It will be configured from time to time.
//---LIN configuration static void lin_init(void) { //initialization //Clock setting NVIC_InitTypeDef NVIC_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; USART_ClockInitTypeDef USART_ClockInitqlt; RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); //---USART2 serial port configuration GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, &GPIO_InitStructure); //Open interrupt NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = NVIC_PREEMPTION_PRIORITY_LIN_UART_RX; NVIC_InitStructure.NVIC_IRQChannelSubPriority = NVIC_SUB_PRIORITY_LIN_UART_RX; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); USART_InitStructure.USART_BaudRate = LIN_BAUDRATE; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; USART_Init(USART2, &USART_InitStructure); USART_ClockInitqlt.USART_Clock= USART_Clock_Disable; USART_ClockInitqlt.USART_CPOL = USART_CPOL_Low; USART_ClockInitqlt.USART_CPHA = USART_CPHA_2Edge; USART_ClockInitqlt.USART_LastBit = USART_LastBit_Disable;// USART_ClockInit(USART2,&USART_ClockInitqlt); USART_ITConfig(USART2,USART_IT_RXNE,ENABLE); USART_ITConfig(USART2,USART_IT_TXE,DISABLE); USART_Cmd(USART2, ENABLE); }
10. Then I thought I'd try it. It is initialized only once at the beginning of the main function. No, the voltage of pin 25 can't reach 3.3V. Still 3.7V.
The configuration is as follows: put it into while and initialize periodically. All right..
void Uart_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, &GPIO_InitStructure); USART_InitStructure.USART_BaudRate = 19200; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; USART_Init(USART2, &USART_InitStructure); USART_Cmd(USART2, ENABLE); }
3, Summary
1.GD32F103 is like ADC acquisition plus DMA transmission. I first configure ADC and then DMA. There is no delay after ADC calibration. Everything is OK. It may have something to do with the hardware, or I have changed the relevant configuration in the library. As mentioned above.
2. Brothers who see this also give me analysis. Discuss it. Why does this configuration pull down the voltage by 3.3V. I will continue to clarify these questions later.