Commissioning experience on VCP (Virtual Com Port) expansion

* The Overview

  Two days ago, the owner received a mandate to deploy, to add to the existing USB CDC (Communication Device Class) function based STM32L151 and L432 of LoRaWAN program and enumerated as VCP (Virtual Com Port) as an alternative to conventional serial printer. I was wondering why when there is no previous structure of the code added to it. . . It is estimated that at that time we all do not understand the CDC.

  Previous development board to serial to USB chip through CP210X, the measured effect is not very good.

CP210X chips also have to manually install the driver on a computer WIN7, the most critical of the cost, but also a part of expenses.

After re-designed L151, L432 node, in turn, canceled the onboard CP210X by VCP way is the smart choice.

   In the process of debugging VCP is not imagine very well, the PC display can be observed after successful enumeration became VCP although it is easy to get through the VCP part, straight port CubeMX L151mircoUSB VCP generated code, and also print relatively smooth.

   Heapsize0x200 not encountered many friends described cause problems CDC enumeration failure in the verification of the VCP, but when transplanted into LoRaMAC VCP part in the work and the workload becomes complicated again. Because LoRaMAC for crystal clock interrupts and peripherals to configure more complex configuration requirements, as well as existing LoRaMAC HAL library project startup files and other documents with the new version are quite different, leading to the implantation of the original LoRaMAC VCP program does not run. There is no basic transplant experience for me, still in the transplant process step on a lot of traps. . .

In order to avoid similar work in the future development needs, so make a note of this important migration of a few places in the process met:

    1. The first thing to note is the port mapping, support for many of the STM32 chip IO port mapping and multiplexing, for example, you can do the same peripherals in different pins. So when configuring peripheral port Note Please do not make a stupid mistake like me, configuration PB67, test PA910 .....

    2. pay attention to whether there is a low-power processing performed by the host IO-portable code, the many high-performance, low-power device application scenarios, in order to achieve the lowest power consumption, will often do not use the IO port low-power process, the general practice is set to IO input. At this time, when the transplant procedure, for example when the graft requires VCP function check to ensure that no low-power pin PA1112 process.

    3. For the new generation of STM32 engineering, Cube will generally peripheral interrupt handler (Handler) function into a file called stm32xxx_it.c, but often the old project code will have their own interrupt handler, it is possible compile the case does not appear that he would repeat the definition of default handler execution is not the one you want, cause you could not find the reason! So attention must be careful and make appropriate adjustments in the interrupt handler. For example, interrupt priority, steals priority, that is, the configuration of the nested loop, for reasonable code logic.

 

After exclusion of the crystal and interrupt priority, and verification of various factors such as SPI communications normal, LoRaMAC program still exists a problem that can not receive the downlink frame. This solved the problem yet, and then studied to be acquired after a business trip.

 

Guess you like

Origin www.cnblogs.com/SaberArthur/p/11128404.html