MCUXpresso enable code define in debug mode

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MCUXpresso enable code define in debug mode

1,240 Views
kensu
Contributor V

Hi,

Can MCUXpresso enable source code define when MCUXpresso is in debug mode "automatically" with some setting?

pastedImage_1.png

Example:

#define _IS_IN_DEBUG_MODE_  //<--  if MCUXpresso is in debug mode, this define is on or defined.

void function()

{

   #if defined(_IS_IN_DEBUG_MODE_  )

    //compiler when    _IS_IN_DEBUG_MODE_ is defined

  #endif

}

Labels (1)
Tags (2)
0 Kudos
5 Replies

681 Views
converse
Senior Contributor V

By default, the symbol "DEBUG" is defined when building the Debug variant of your code and NDEBUG is defined for the Release build. So you can use

#if defined(DEBUG)

....

#endif

0 Kudos

681 Views
kensu
Contributor V

Hi

Thanks for reply.

But I am looking for a method for build different code "in debugger mode which LPC-Link2 is connected".

Is it possible?

Not the DEBUG & RELEASE mode.

Thank you

Ken

0 Kudos

681 Views
converse
Senior Contributor V

But you said that you were looking for a compiler #define which by definition must be a build mode. Please state what it is you are really looking for and why.

0 Kudos

681 Views
kensu
Contributor V

Hi,

I paste a picture when I ask this question, I want to make MCUXpresso to enable code define.

pastedImage_1.png

Now, I am using LPC-Link2 to download AXF file and the application is run without debugger(I called it normal mode), and I also use LPC-Link2 to debug(check memory, step by step...) in debugger mode.

My pirntf function is implement by USB Virtual Comport. It work fine when I download AXF file in normal mode.

But Virtual comport usually disconnect when I enable debugger mode.

So I let the log message output from Semihosting.

I read some article, it can check the cortex-M3 status bit to check it the debugger bit is enabled. 

I use this method, it works. So my printf function will check this bit to determine if it need output from semihosting.

But one problem happened.  In normal mode, I use LPC-Link2 only for download, not need to enter debugger mode, after download complete, my application will detect the debugger bit is on, It try to output log message from semihosting(but it is not in debugger mode), then it halt. I think the reason is I use LPC-Link2 to download AXF, in this procedure, it will also enable debugger bit.

So solution is I re-connected LPC-Link2 again, then the debugger bit will be 0, my printf will output from VCOM. But it is not good, because the first time download, it always halt.

So, my purpose is I want to change my printf function to semihosting while I am using LPC-Link2 debug mode. I hope the MCUXpresso will enable define so that my priint function will be compiler to semihosting mode.

Thanks

Ken

 

0 Kudos

681 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Ken Su,

  I don't know which LPC chip you are using as the target board.

  If you are using the LPC54XX series, you can use the KSDK2.2, when import the KSDK2.2 sample code, there has a item to select the semihost function:

pastedImage_1.png


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos