How does one debug an Interrupt Handlers without semihosting?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How does one debug an Interrupt Handlers without semihosting?

ソリューションへジャンプ
2,629件の閲覧回数
jmueckl
Contributor IV

I have been experiencing difficulty stepping through interrupt handlers I have written for SPI, perhaps due to the limitations of Semihosting.  I am able to step through my interrupt handler once, but then after that my interrupt handler is mysteriously being called again even after I have disabled interrupts using the code

SPI_DisableInterrupts(SPI9, kSPI_TxLvlIrq | kSPI_RxLvlIrq );

 

From the MCUXpresso IDE User Guide I understand that there is a way to turn off the Semihosting, but I can’t find the method to do that.  I would like to place a counter in my interrupt handler, and after it has been called use a printf to display the number of times the handler has been called.  Will someone please tell me how to do that in the MCUXpresso IDE.

 

I am working with the LPC54018 development board OM4003.  I began with the project lpcxpresso54018_spi_interrupt_b2b_master but significantly modified it. 

ラベル(1)
タグ(2)
0 件の賞賛
返信
1 解決策
2,579件の閲覧回数
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

Pls refer to the following screenshot to know the switch between Uart and semihost. The first step is to select the project.

Hope it can help you

BR

XiangJun Rong

xiangjun_rong_0-1616037643401.png

 

元の投稿で解決策を見る

0 件の賞賛
返信
9 返答(返信)
2,594件の閲覧回数
frank_m
Senior Contributor III

That depends on your intentions. With debugging, you mean "wanting to know what happens inside".

For checking the timing, and timing relation to other events/interrupts, you can add instrumentation code to toggle GPIO pins. That helps you visualize the timing, using a scope or logic analyser.

For checking values and states inside the handler, you can store those of one or multiple runs in array, and output them offline later, e.g. via semihosting. That requires instrumentation code as well.

I once worked on a project with a MCU core on an ASIC, were the project manager had decided to go along without debug interface (which turned out more costly later on ...). We used sequential toggles of an available GPIO to output events/state for debugging purposes - again with a scope.

0 件の賞賛
返信
2,581件の閲覧回数
jmueckl
Contributor IV

Thank you all for the information you have shared. It all helps.  Now can someone now answer my former question as follows?  

I already created my project with semihosting.  Is there an easy way to convert to UART without having to create a new project?  Also, can I easily convert the project from UART back to a semihosting again? 

I cannot find a "button" that will do this.  It appears that I have to create a new project and select UART instead of Semihosting, and then copy all the code I wrote in the semihosting project to the UART project.

0 件の賞賛
返信
2,625件の閲覧回数
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Jerry,

I do not think it is okay to put the printf() function in the interrupt handler function, because the printf() function is a time-consuming work. pls comment the printf(), for test purpose, toggle a GPIO in the interrupt handler function, does the GPIO toggle repeatedly?

Hope it can help you

BR

XiangJun Rong

0 件の賞賛
返信
2,622件の閲覧回数
jmueckl
Contributor IV

It is not my intention to put the printf in the ISR handler.  I will put a counter variable in the ISR handler and have it printed in main.  But my question here is how do I tell MCUXpresso to avoid using semihosting so I can perform my testing, and then how do I restore the semihosting features after testing? 

The following is copied from the MCUXpresso IDE User Guide:

When you have linked with the semihosting library, your application will no longer work standalone – it will only work when connected to the debugger. Semihosting operations cause the CPU to drop into “debug state”, which means that for the duration of the data transfer between the target and the host PC no code (including interrupts) will get executed on the target. Therefore, if your application uses interrupts, then it is normally advisable to avoid the use of semihosting whilst interrupts are active – and certainly within interrupt handlers themselves. If you still need to use printf, then you can retarget the bottom level of the C library to use an alternative communication channel, such as a UART or the Cortex-M CPU’s ITM channel.

0 件の賞賛
返信
2,580件の閲覧回数
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

Pls refer to the following screenshot to know the switch between Uart and semihost. The first step is to select the project.

Hope it can help you

BR

XiangJun Rong

xiangjun_rong_0-1616037643401.png

 

0 件の賞賛
返信
2,565件の閲覧回数
jmueckl
Contributor IV

This is what I was looking for, a way to switch between semihosting and UART modes without creating a new project.  This should be in the MCUXpresso IDE User Manual.  If it is, I didn't see it.  If there is any further documentation I have missed, please let me know.

0 件の賞賛
返信
2,615件の閲覧回数
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Jerry,

When you import a project or create a new project based on SDK package, pls select the UART instead of semihost as the following figure:

Hope it can help you

BR

XiangJun Rong

xiangjun_rong_0-1615961621449.png

 

0 件の賞賛
返信
2,610件の閲覧回数
jmueckl
Contributor IV

I already created my project with semihosting.  Is there an easy way to convert to UART without having to create a new project?  Also, can I easily convert the project from UART back to a semihosting again?

0 件の賞賛
返信
2,600件の閲覧回数
converse
Senior Contributor V

To find more information on semihosting:

https://community.nxp.com/t5/LPCXpresso-IDE-FAQs/What-is-Semihosting/m-p/475390

And follow the link at the bottom for how to change the library type.

0 件の賞賛
返信