I've written a program for a cynal 8051F000 microprocessor, compiled and linked it with SDCC without any problem, and then downloaded it to the microprocessor. However when I try to run it it never escapes from the GSINIT area of code, so main() never gets called. When I've tried looking with a debugger it appears to be writing values across memory (not initialisation). Can anyone suggest anything?
Thanks,
Stephen
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is a problem I had with my C8051F310. The time it takes for the SDCC initialisation routines causes the Watchdog to time out. You can check this in RSTRSC - at least I hope so for the 'F000.
I added the command line switch '--no-xinit-opt' to the batch file (I cannot use the new Silabs IDE as I insist that I have SDCC in the Program Files folder). It then reaches main() and allows me to turn off the watchdog until I am ready.
My crystal is 25Mhz and is divided by 2 for SYSCLK.
That said, if the remaining SDCC initialisation routines still take too long, then I'm not sure what to do.
Best regards,
Tony Pemberton
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It was the watchdog timing out, although I have to admit it was because an error in one of my header files was giving it a lot of unnecessary initialisation to do.
Stephen
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
To disable the watchdog before the initializations take place you can write a function:
char _sdcc_external_startup(void)
and disable it there. Have a look at the manual 3.11.1
Maarten
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I had looked at this section of the manual, but I was confused by its meaning. I took the '--no-xinit-opt' as an easy way out.
Today, however, I have recompiled my _startup.c with the (almost) following code and this works with variable initialisation. I do use a define file for the specific processor, but I have omitted this for clarity.
The downside of modifying the library routine is that every time a SDCC snapshot is downloaded, the library gets overwritten! (Aaargh! Who found this out the hard way?).
Tony Pemberton
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
At first I thought you understood it, but the last message makes me believe otherwise.
You don't update the library routine, you write your own version in your own sources. SDCC looks for the function and finds it first in your sources and does not have to resort to looking in the library. That's what overriding is all about.
An update for the manual can be posted in the patches area.
Maarten
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've written a program for a cynal 8051F000 microprocessor, compiled and linked it with SDCC without any problem, and then downloaded it to the microprocessor. However when I try to run it it never escapes from the GSINIT area of code, so main() never gets called. When I've tried looking with a debugger it appears to be writing values across memory (not initialisation). Can anyone suggest anything?
Thanks,
Stephen
Stephen,
This is a problem I had with my C8051F310. The time it takes for the SDCC initialisation routines causes the Watchdog to time out. You can check this in RSTRSC - at least I hope so for the 'F000.
I added the command line switch '--no-xinit-opt' to the batch file (I cannot use the new Silabs IDE as I insist that I have SDCC in the Program Files folder). It then reaches main() and allows me to turn off the watchdog until I am ready.
My crystal is 25Mhz and is divided by 2 for SYSCLK.
That said, if the remaining SDCC initialisation routines still take too long, then I'm not sure what to do.
Best regards,
Tony Pemberton
Thanks Tony.
It was the watchdog timing out, although I have to admit it was because an error in one of my header files was giving it a lot of unnecessary initialisation to do.
Stephen
Stephen, Tony,
To disable the watchdog before the initializations take place you can write a function:
char _sdcc_external_startup(void)
and disable it there. Have a look at the manual 3.11.1
Maarten
Maarten,
I had looked at this section of the manual, but I was confused by its meaning. I took the '--no-xinit-opt' as an easy way out.
Today, however, I have recompiled my _startup.c with the (almost) following code and this works with variable initialisation. I do use a define file for the specific processor, but I have omitted this for clarity.
unsigned char _sdcc_external_startup ()
{
// e.g disable C8051F310 watchdog timer
PCA0MD = 0x00; // WDTE = 0 (clear watchdog timer enable)
// Watchdog disabled, initialise static and global variables
return 0;
}
I have re-written the manual page for my benefit, but I do not know where the suggested text might be posted!
Best regards,
Tony Pemberton
The downside of modifying the library routine is that every time a SDCC snapshot is downloaded, the library gets overwritten! (Aaargh! Who found this out the hard way?).
Tony Pemberton
Tony,
At first I thought you understood it, but the last message makes me believe otherwise.
You don't update the library routine, you write your own version in your own sources. SDCC looks for the function and finds it first in your sources and does not have to resort to looking in the library. That's what overriding is all about.
An update for the manual can be posted in the patches area.
Maarten