Calling functions from the debugger

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

Calling functions from the debugger

Jump to solution
1,492 Views
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
Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
730 Views
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

View solution in original post

0 Kudos
Reply
1 Reply
731 Views
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 Kudos
Reply