This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

memory

Hello

I Always used Atmel AT89C51RE2 but there the production stopped we changed over to
Silicon C8051F580 processor.

now I am facing problems with the memory.
when I add variables after downloading the program wont run.
the compiler give Program Size: data=78.3 xdata=172 code=10749

so to mine point there is enough space.
maybe something with parameters?

with regards

Jos

Parents
  • when I add variables after downloading the program wont run.

    Probably means something like:

    When I've added variables to the project and rebuilt then the download won't run.

    Maybe my having a wife who speaks English as a second language makes it easier for me to translate such sentences on the fly (?)

    Anyway, obvious area to look is memory allocation. So examination of map files and regular debugging would be a sensible path to follow.

Reply
  • when I add variables after downloading the program wont run.

    Probably means something like:

    When I've added variables to the project and rebuilt then the download won't run.

    Maybe my having a wife who speaks English as a second language makes it easier for me to translate such sentences on the fly (?)

    Anyway, obvious area to look is memory allocation. So examination of map files and regular debugging would be a sensible path to follow.

Children
  • Presumably, just don't just add variables - that would be pointless without also adding code to use those variables.

    So, as well as the memory allocation, you need to look at that code.

    As already noted, use the debugger.

    Add printfs and/or other instrumentation to see what your code is doing.

    Carefully compare before & after the changes ...

  • Presumably, just don't just add variables - that would be pointless without also adding code to use those variables.

    Wow. You are a Mr Smarty-Pants. lol.

  • was your port to the SiLabs part thoroughly tested and debugged before you started adding/changing stuff ?

  • what do you mean?
    when I add variables after downloading HOW?.
    when I add variables to my sode the program wont run.

    porting toa 589, you, typically missed a set of SFRPAGE

  • this is discussed in parallel on the SiLabs forum

  • of course I use those variables in mine code

    I have seen that when I have to many variables the program wont run.
    so debugging is also impossible.

    I have declarede arrays of 1000 bytes no problem.

    I shall look to the amound of variables and try to decrease those.

  • Hallo Erik

    can you send me a link to this topic of Silicon?
    thanks

  • Of course the program runs.

    There are only 3 ways to stop a CPU from running:
    1. no power;
    2. something external is holding it in reset;
    3. your code has put it into a "sleep" state.

    Otherwise, the CPU will always be running; ie, fetching stuff from CODE memory, and executing it.
    Of course, what it's fetching may be junk - but it will still be running.

    "so debugging is also impossible."

    Not at all! The debugger lets you see where it's going wrong!

  • OK - make that four:

    4. The clock has stopped.

  • Go on. You started that topic - surely you know where it is?

    Again, note that the name is Silicon Labs. (if that's too much for you to type, just say "SiLabs").

  • Hello Andrew

    thanks for your response.

    I will try to explain what I am doing.

    Our company has a monitorsystem and I am working on the substations.
    Normally the substations do not have the ability to store measurements.
    This is what I am trying to achieve.

    on the old board with the AT89C51RE2 it works.

    but as I told before this processor is obsolete and we changed over to C8051F580

    what should have same memory space.

    First I get the firmware running without datalogging, to see if the hardware was ok.
    now I am adding the routinges for datalogging.
    therefore I need more variables, after adding those variables the problems starts.

    the program did not start.

    in the C8051F580 I use a startup program and found out that the program hangs in the first
    routine ( I will add a part of the code later)
    when I reduce the amount of variables it runs again.

    Now I am using some structures, what seems to work but I find that the variables are corrupted.

    maybe I use some wrong arguments in the code (pragma?)

    here the startup file

    ?C_STARTUP: LJMP STARTUP1

    RSEG ?C_C51STARTUP

    STARTUP1:

    IF IDATALEN <> 0 MOV R0,#IDATALEN - 1 CLR A
    IDATALOOP: MOV @R0,A DJNZ R0,IDATALOOP
    ENDIF

    I use this argument in the main routine

    SFRPAGE = ACTIVE_PAGE;

    if you can help me further, please

    thanks in advance

    Jos

  • So where, exactly, is it hanging?

    And what, exactly, is the point at which it goes from "working" to "hanging"?

    Look at the instructions for posting source code: www.danlhenry.com/.../keil_code.png

  • you are missing the watchdog disable in startup

  • this is mine memory model

    //memory model for Titan
    //version:
    //date 02 march 2018
    
    #include "defines.h"
    #include "memory.h"
    
    
    signed char iPos = -1;                                  //pointer received data
    signed char xdata channel=0;
    signed char xdata Address;
    signed char xdata iMessLen=0;
    unsigned char idata hexstring[8];
    unsigned char xdata Uart_Buffer_Pointer = 0;
    //unsigned char xdata Uart[Uart_Buffer_In_Size];
    unsigned char xdata rMessage[Uart_Buffer_In_Size];                              // data for processcom
    unsigned char xdata sMessage[Uart_Buffer_Out_Size];                     // data for Sendbuffer
    unsigned char xdata LMessage[Uart_Log_Output];
    unsigned char idata Uart_Tx_Index;
    unsigned char idata Uart_Tx_SendLen;
    unsigned char idata mem[0x10];
    unsigned char idata CalData[0x10];
    
    
    
    
    unsigned char idata ScheduledKanalen=0x00;   // Mask of kanalen used in scheduling
    unsigned char idata MeasuredKanalen=0x00;    // Mask of kanalen measured since last readout
    signed int xdata Kanalen[NUMANAIN] = {-32768,-32768,-32768,-32768};
    unsigned char xdata Dig[2];                // Control for digital in and out
    unsigned char LRCResult();
    unsigned char xdata ucLRC;
    
    //clock
    //signed int date=0;
    long idata seconds=0;
    long idata longvalue=0;
    
    
    //datalogging
    bit memory_overwrite_flag = 0;
    bit memory_overflow_flag = 0;
    bit setlogging_flag =0;
    bit forced_logging_flag =0;
    bit setmask_flag = 0;
    
    //uart
    bit uart_rx_valid=0;                                            //data received valid
    bit uart_tx_flag=0;                                             //data transmitted valid
    bit ti_1_busy;
    bit rx_valid;
    bit sendserialnumber;
    bit TX_Ready =0;
    
    struct TimeProfile idata Tprofile;
    struct LogProfile idata Lprofile;
    

    this is the start of mine program


    SFRPAGE = ACTIVE_PAGE; PCA0MD &= ~0x40; // Disable watchdog timer
    PORT_Init(); // Initialize Port I/O
    SYSCLK_Init (); // Initialize Oscillator
    TIMER0_Init (); // Initialize Timer0
    TIMER2_Init (); // Initialize Timer2
    SPI0_Init ();
    UART0_Init (); // Initialize UART LED_1 = OFF;
    LED_2 = OFF; LED_3 = OFF; //SFRPAGE = ACTIVE2_PAGE; //disabling this line will activate wd but out of control EA = 1;
    RX_EN = OFF;
    TX_EN = OFF;
    readcaldata();
    ADC_Init();
    Watchdog_Init ();
    if ((RSTSRC & 0x02) == 0x00) // First check the PORSF bit. if PORSF
    { // is set, all other RSTSRC flags are // invalid // Check if the last reset was due to the Watch Dog Timer if (RSTSRC == 0x08) { EA = 1; // Enable global interrupts } } // Calculate Watchdog Timer Timeout
    // Offset calculated in PCA clocks
    // Offset = ( 256 x PCA0CPL5 ) + 256 - PCA0L
    // = ( 256 x 255(0xFF)) + 256 - 0
    // Time = Offset * (12/SYSCLK)
    // = 255 ms ( PCA uses SYSCLK/12 as its clock source) PCA0MD &= ~0x40; // Disable watchdog timer
    PCA0L = 0x00; // Set lower byte of PCA counter to 0
    PCA0H = 0x00; // Set higher byte of PCA counter to 0
    PCA0CPL5 = 0xFF; // Write offset for the WDT
    PCA0MD |= 0x40; // Enable the WDT watchdog still not working well EA = 1; // Enable global interrupts </prev> Also I use the standard startupfile from Keil/Silicon