Keil Logo

memory

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Author
jos spronk
Posted
31-Jul-2018 21:18 GMT
Toolset
C251
New! 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

Author
Westonsupermare Pier
Posted
31-Jul-2018 21:55 GMT
Toolset
C51
New! maybe something with parameters?

Maybe time to break out the documentation and the debugger, and figure out what the processor is objecting too?

Take a listing file, walk the code, add diagnostics.

Author
Andrew Neil
Posted
1-Aug-2018 01:06 GMT
Toolset
C251
New! RE: I add variables after downloading

How can you add variables after downloading?

Note that the C8051F580 is not a C251

Author
Kevin Wrangal
Posted
1-Aug-2018 07:46 GMT
Toolset
C251
New! RE: I add variables after downloading

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.

Author
Andrew Neil
Posted
1-Aug-2018 08:03 GMT
Toolset
C251
New! RE: I add variables

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 ...

Author
Andrew Neil
Posted
1-Aug-2018 08:05 GMT
Toolset
None
New! How To Debug


https://www.avrfreaks.net/comment/2418156#comment-2418156

Author
Kevin Wrangal
Posted
1-Aug-2018 08:30 GMT
Toolset
None
New! RE: How To Debug

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.

Author
Andrew Neil
Posted
1-Aug-2018 08:43 GMT
Toolset
None
New! RE: we changed over to Silicon [Labs] C8051F580 processor.

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

Author
erik malund
Posted
1-Aug-2018 13:30 GMT
Toolset
None
New! RE: we changed over to Silicon [Labs] C8051F580 processor.

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

Author
erik malund
Posted
3-Aug-2018 15:22 GMT
Toolset
None
New! RE: we changed over to Silicon [Labs] C8051F580 processor.

this is discussed in parallel on the SiLabs forum

Author
Jos Spronk
Posted
7-Aug-2018 10:20 GMT
Toolset
C51
New! RE: we changed over to Silicon [Labs] C8051F580 processor.

Hallo Erik

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

Author
Andrew Neil
Posted
8-Aug-2018 12:36 GMT
Toolset
C51
New! RE: can you send me a link to this topic of Silicon?

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").

Author
Jos Spronk
Posted
7-Aug-2018 09:34 GMT
Toolset
C51
New! RE: I add variables after downloading

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.

Author
Andrew Neil
Posted
8-Aug-2018 09:20 GMT
Toolset
C51
New! RE: program wont run

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!

Author
Andrew Neil
Posted
8-Aug-2018 10:51 GMT
Toolset
None
New! RE: There are only 3 ways to stop a CPU from running

OK - make that four:

4. The clock has stopped.

Author
Jos Spronk
Posted
9-Aug-2018 07:44 GMT
Toolset
C51
New! RE: There are only 3 ways to stop a CPU from running

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

Author
Andrew Neil
Posted
9-Aug-2018 08:48 GMT
Toolset
C51
New! RE: the program hangs in the first routine

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: http://www.danlhenry.com/caps/keil_code.png

Author
erik malund
Posted
10-Aug-2018 16:05 GMT
Toolset
C51
New! RE: the program hangs in the first routine

you are missing the watchdog disable in startup

Author
Jos Spronk
Posted
13-Aug-2018 09:20 GMT
Toolset
C51
New! RE: the program hangs in the first routine

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
Author
erik malund
Posted
13-Aug-2018 13:36 GMT
Toolset
C51
New! RE: the program hangs in the first routine

who cares about your memory model, your problem is not disabling the WD in startup

Author
Andrew Neil
Posted
13-Aug-2018 14:57 GMT
Toolset
C51
New! RE: who cares about your memory model,

and it's incomplete, anyhow; eg, where are the array size definitions?

Not sure that this would generally be called a "memory model" - it's just a list of (presumably global?) variables.

Author
erik malund
Posted
14-Aug-2018 13:21 GMT
Toolset
C51
New! RE: who cares about your memory model,

https://www.silabs.com/community/mcu/8-bit/knowledge-base.entry.html/2014/07/09/mcu_constantly_reset-2DbM

Author
Jos Spronk
Posted
14-Aug-2018 13:56 GMT
Toolset
C51
New! RE: who cares about your memory model,

thanks Erik

I will try
Jos

Author
Andrew Neil
Posted
14-Aug-2018 15:06 GMT
Toolset
C51
New! RE: who cares about your memory model,

Note that this was the very first reply given to your cross-post on the SiLabs forum:

https://www.silabs.com/community/mcu/8-bit/forum.topic.html/hello_i_am_jos-5BRm

Thus showing the importance of keeping up-to-date with all the threads if you're going to cross-post the same questions to multiple places!

Be sure to go back and thank 'delu' on the SiLabs forum ...

Next Thread | Thread List | Previous Thread Start a Thread | Settings

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.