Dynamic reuse of serial port debugging under WinCE

Source: Internet
Author: User

 

Many serial peripherals are used in the automotive terminal project, such as DVD movement, GPS, Bluetooth, radar, and tire pressure monitoring. The main CPU (TCC89XX) and small MCU (STM32) through serial communication. For a moment, the serial port is a little too slow to use. You can only use the debug serial port for common serial ports.

It is no problem to debug the serial port as a common serial port. It has been done on the S3C2410 before. At that time, the serial port of 2410 was forced to be changed to a common serial port. After the system was started, the serial port could not be used properly after debugging. However, the current project is still being improved, and debugging the serial port is still very important. It is often necessary to analyze and locate problems through TRACE. Therefore, we hope that UART0 can be easily switched between the debugging serial port and the common serial port.

At the same time, it seems impossible for UART0 to debug both the serial port and common serial port, and it has little significance. A simple method is considered. UART0 is used as a common serial port by default. When you need to capture traces, configure the UART0 working mode in the application to debug the serial port, and then restart the system.

Anyone familiar with the WinCE6.0 startup process knows that the initialization of the debug serial port is at the initial stage of the WinCE kernel startup. I have introduced the "Detailed description of the WinCE6.0 startup process under the S3C2410". If you are interested, you can take a look. The serial port initialization code is usually in the Src \ OAL \ OALLIB \ debug. c file under the BSP directory. In this file, we made two major changes.

1 void OEMInitDebugSerial ()

2 {

3 pVirtualBOOTARGS = (tSYSTEM_PARAM *) OALPAtoVA (SYSTEM_PARAM_BASEADDRESS, FALSE );

4}

The virtual address used to obtain system configuration parameters is added here.

1 //------------------------------------------------------------------------------

2 //

3 // Function: OEMWriteDebugString

4 //

5 // Output unicode string to debug serial port

6 //

7 VOID OEMWriteDebugString (UINT16 * string)

8 {

9 if (! PVirtualBOOTARGS-> SysConfig. fDisableDebugSerial)

10 {

11 while (* string! = L' \ 0') OEMWriteDebugByte (UINT8) * string ++ );

12}

13}

Among them, pVirtualBOOTARGS-> SysConfig. fDisableDebugSerial is a variable that controls whether the debug serial port outputs characters normally. SysConfig is a struct stored in a specific area of NAND Flash. It can be read during BOOT and stored in a specified location in the memory. The structure can be modified in the application. The related code is as follows.

1 void SysDisableDebugSerial (int nDisable)

2 {

3 GetSysConfig (& gSYSCONFIG );

4 gSYSCONFIG. fDisableDebugSerial = nDisable;

5 SetSysConfig (& gSYSCONFIG );

6}

7

8

9

10 void CSysAppDlg: OnBnClickedCheckDebugserial ()

11 {

12 // TODO: add the control notification handler code here

13 CReg Reg;

14

15 UpdateData (TRUE );

16 SysDisableDebugSerial (m_bDisableDebugSerial );

17

18 Reg. Open (HKEY_LOCAL_MACHINE, _ T ("Drivers \ BuiltIn \ seri_3"), KEY_ALL_ACCESS );

19 Reg. SetSZ (_ T ("Dll"), m_bDisableDebugSerial? _ T ("tcc_serial.dll"): _ T ("-tcc_serial.dll "));

20 Reg. Flush ();

21}

As you can see, when modifying the variable fDisableDebugSerial, you also need to modify the Registry corresponding to UART0. When the debug serial port is disabled, the DLL key value is set to correct. When the debug serial port is enabled, add a horizontal bar before the DLL key value. Make sure that UART0 is either used as the debugging serial port or as the common serial port. Shows the application settings page.

 

Www.2cto.com

After testing, the above modifications basically achieve the expected results, and achieve dynamic reuse of the serial port debugging under WinCE.

 

From longtotem's blog

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.