Calling functions from the debugger

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Calling functions from the debugger

跳至解决方案
2,112 次查看
etolocka
Contributor I
Hi

Can I run a function of my source code from within the debugger?

Suppose I have a function called "Bip" to make a sound with a buzzer. With the code loaded in the target and the simulator halted, can I call this function to test how it works?

I tried to add it to the Data Objetc window, as an expression, but does not work?

Any advice about this?

Thankfully,
Ernesto.



Message Edited by etolocka on 2008-01-23 05:58 PM
标签 (1)
标记 (1)
0 项奖励
回复
1 解答
1,350 次查看
J2MEJediMaster
Specialist I
You need to specify the target MCU and CodeWarrior version to get a correct answer. I'll give it a shot anyway, assuming a HCSX MCU.

Once you've downloaded the code, you're staring at the True-Time Simulator window. Locate the function you want to execute by choosing Source | Find Procedure... and then enter your function name. Click OK, and you'll land at the first executable source line your function. Now right-click in the source window and choose Set Program Counter from the drop-down menu. Now you can single-step or execute the function's code from this point. However, keep in mind that you've just by-passed a lot of initialization code that sets up the peripheral for output and configures its features. So, you may not get the results that you expect.

You can work around the initialization problem if your program isn't using an OS. Go to the project's Debugger Settings panel (type Alt-F7 in the CW IDE to get there) and in the Stop on application launch section, click on the User Specfied button and enter main() into the text entry box. Now when the program loads, the simulator starts and executes all functions (which most likely handle the device setup) up until main(). Now readjust the program counter and try executing the function. Still no guarantee that some key bit of initialization code has been overlooked, but it's worth a try.

---Tom

在原帖中查看解决方案

0 项奖励
回复
1 回复
1,351 次查看
J2MEJediMaster
Specialist I
You need to specify the target MCU and CodeWarrior version to get a correct answer. I'll give it a shot anyway, assuming a HCSX MCU.

Once you've downloaded the code, you're staring at the True-Time Simulator window. Locate the function you want to execute by choosing Source | Find Procedure... and then enter your function name. Click OK, and you'll land at the first executable source line your function. Now right-click in the source window and choose Set Program Counter from the drop-down menu. Now you can single-step or execute the function's code from this point. However, keep in mind that you've just by-passed a lot of initialization code that sets up the peripheral for output and configures its features. So, you may not get the results that you expect.

You can work around the initialization problem if your program isn't using an OS. Go to the project's Debugger Settings panel (type Alt-F7 in the CW IDE to get there) and in the Stop on application launch section, click on the User Specfied button and enter main() into the text entry box. Now when the program loads, the simulator starts and executes all functions (which most likely handle the device setup) up until main(). Now readjust the program counter and try executing the function. Still no guarantee that some key bit of initialization code has been overlooked, but it's worth a try.

---Tom
0 项奖励
回复