Menu

Program never gets to the main() function

Steve P
2004-07-19
2004-07-22
  • Steve P

    Steve P - 2004-07-19

    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

     
    • tony_pemberton

      tony_pemberton - 2004-07-20

      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

       
    • Steve P

      Steve P - 2004-07-20

      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

       
    • Maarten Brock

      Maarten Brock - 2004-07-21

      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

       
    • tony_pemberton

      tony_pemberton - 2004-07-21

      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

       
    • tony_pemberton

      tony_pemberton - 2004-07-22

      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

       
    • Maarten Brock

      Maarten Brock - 2004-07-22

      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

       

Log in to post a comment.