I have written some code for a Silabs C8051F330 CPU, compiled it and then obviously some C51STARTUP code is generated that initialize the variables. Using my USB debug adaptor I discover the execution got stuck in the C51STARTUP code and it never exits it to the main program. What could be a possible cause for this and how can I fix it?
So where, exactly, does it get stuck?
Look at the code and think about what's preventing it from exiting - eg, what condition is not being met?
I will do that, only problem is I need to jump into the assembler code and figure out what it is doing and which variable it is trying to do what with. The asm code is a JC instruction back to the some place down from the start of the C51STARTUP code. In it a bit difficult to determine the actual operation from the assembler if you don't know what it is trying to do. I will give it a go!
The Watchdog Timer of the 330 is enabled on reset. So is most likely that your startup code takes too long -> the watchdogs times out, resets the 330 and you'll never reach the main function.
So add a copy of the startup code to your project and disable the watchdog as early as possible.
Or modify the startup code to ensure that it keeps the watchdog from timing out...
What do you mean with "Or"? He does not reach the main function, so this is the only place I can think of. Am I missing something?
I don't know if it is the watchdog timing out. I use the USB Debug adapter and I can see it tries to initialize some variables using strange Assembler code. The variables are simple unsigned integers and bits, no arrays. Thus it should be quick. I can see, single stepping, where it loops back to about 10 instructions after the C_STARTUP code and doing the same thing over and over again. I going to remove the variable initialization part and will do that in the main program en see what happen. This can only happen tomorrow.
I mean he could either just disable the watchdog or make the startup code "kick" the watchdog at appropriate points so that it doesn't time out.
(Both of which, of course, assume that the problem is actually due to the watchdog)
Doesn't the standard startup code include zeroing all of XDATA...?
I mean he could either just disable the watchdog or make the startup code "kick" the watchdog at appropriate points so that it doesn't time out. kicking is not advised, there are, in some cases, more time spent between startup and main than in startup.
besides the OP refer to 'strange assembler code', the code in startup is as simple as can be.
we are back a the old point "to do embedded you need, at least, some assembler.
Erik
View all questions in Keil forum