GD32F303 debugging notes (4) Special GPIO usage (PC13~PC15, PA0 are used as ordinary output IO)

Preface

In recent projects, the GD32F303Rx series of microcontrollers are used as the main control chip. Since the functions of the entire product design are relatively complex, IO is almost used. When initially drawing the schematic wiring, some GPIOs with special functions were used. Compared with general IO, the same software configuration was found to have certain problems during the actual verification process. This article cannot be said to have fundamentally solved the problem. It can only be said that the envisioned output logic level has been achieved from the final effect .

IO pin: PC13~PC15

  • Let’s first look at the pin functions of PC13~PC15
  • When the external low-speed clock and internal RTC clock are not used, these three pins are GPIO by default.
    Please add image description
  • Take another look at the instructions in the manual
    Please add image description
    Please add image description
  • Judging from the above summary, although PC13~P15 can be used as ordinary GPIOs, their input and output characteristics are much worse than other general-purpose IOs due to the internal design of the chip. First of all, the maximum operating speed is 2MHz . Secondly, because it is powered by a power switch internally, the ability to source and sink current is greatly reduced . So after understanding their description, we understand that even when the code configuration is accurate, the driving capabilities of these IOs are far less than other general IOs . Therefore, when using it, be sure to pay attention to whether it can drive peripheral related circuits.

IO pin:PA0

  • When low-power wakeup and other mappings are not used, this pin defaults to GPIO.
    Please add image description
  • Take another look at the instructions in the manual
    Please add image description
    Please add image description
  • The above only describes the role of PA0 when exiting sleep and waking up. There seems to be nothing else. I did not find any other special introduction about PA0 through keyword search.

question

  • Here we no longer capture the waveform to demonstrate the IO output phenomenon, but directly talk about the problems that arise.
  • I use these four IOs as analog communication data ports and drive stepper motor output control waveform ports, and they are all configured as push-pull outputs . In this case, level conversion under other general IO levels is not implemented. When the microcontroller is powered by 3.3V , when the output of PC13~PC15 is configured to 0 , the output is low (around 0V) . When configured to 1 , the output is still low (around 0.6V) and cannot completely pull up the power supply (3.3V). . PA0 is a bit opposite. When the output is configured as 1 , the output is high (about 3.3V) . When the output is configured as 0 , the output is still high (about 2.7V) and cannot be completely pulled to ground (0V).
  • 1. After eliminating your own connections and peripheral devices, even if the output is left floating, the problem still cannot be solved.
  • 2. No exception was found by reading the data of the corresponding IO register.

Solution (Treatment of symptoms)

  • For some unknown reason, changing the code configuration when operating these IOs does not achieve the desired output control. At this time we can slightly modify the peripheral devices.
  • We configure the above IO from push-pull output to open-drain output . Since it can only maintain one level, then we let it control one level, and the other level is provided by an external auxiliary circuit (external pull-up).
  • First verify whether IO can only output low level without external pull-up after configuring it as an open-drain output . In this case, when the configured output of PC13~15 is 0 , the output is low (around 0V) . When configured as 1 , the output is still low (around 0V) . In this case, when the output of PA0 is configured as 0 , the output is low (about 0V) . When it is configured as 1 , the output is still low (about 0.3V) .
  • After all are configured with external pull-ups , in this case, PC13~15, when the output is configured as 0 , the output is low (about 0V) , and when it is configured as 1 , the output is high (about 2.6V) . In this case, when PA0 is configured as 0 , the output is low (about 0.3V) , and when configured as 1 , the output is high (about 3.3V) .
  • Based on the above phenomenon, we found that the external pull-up has obvious effects, but it is still different from what we imagined. The high and low levels are still not ideal states.
  • Think about our digital circuits at this time. Whether it is high level or low level, there is a threshold range . Not only 0V is considered low, but 3.3V is considered high. At this time, we looked through the chip manual and found that the GD32 specification stated: 0.3VDD and below is low level, and 0.7 and VDD above is high level . The peripheral driver chip also has a range definition for the judgment of high and low levels. So whether it is 2.6V or 0.3V, it meets my high and low level requirements this time. Then the above solutions can solve the problems faced.

Summary and questions

  • Although the above problems have been solved this time, they are not a cure. Again I have a few questions:
  • For these special IO ports, if you want to use them as push-pull outputs, what should you pay attention to in the chip PCB layout (power supply connections, etc.).
  • Are there any points that need attention in the code configuration? If so, can you point them out?

Guess you like

Origin blog.csdn.net/qq_37554315/article/details/121333301