Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Data buffer of 500 bytes

Status
Not open for further replies.

RyanHan

Junior Member level 3
Joined
Apr 24, 2012
Messages
26
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,514
Dear Expert,

I have a MCU Dallas DS89C450 with the follow memory map as attached. I need to declared a Data buffer of 1kbyte as follows

Data1[500], Data2[500];

However, I am quite confused as to where can I declared my variable. The MCU has 1kB SRAM and 16kB Flash memory. I am using Keil C programming but I am not sure how can I declare this 1kB data variable and how to read and write from it using Keil C.

I tried to compiled unsigned char Data1[500], Data2[500]; and the the compiler give memory error.

Anyone know Keil C programming to access my 1kB of SRAM so that I can read and write from it pls help

Thanks a lot

memory map.jpg
 

First up, if you try and create those arrays in SRAM then even if they are of type char.. you've just used up 99% of your 1kb memory. What data types are Data1[] and Data2[]?? If they are constant i.e. you know what the values of each array element is (e.g. a bit stream to configure an SPI device) declare the array as const (i.e. const char Data1[500] = {a, b, c...} all your 500 values). This will go into program memory at compile time and be stored in your flash. Obviously you will only be able to read it.. not write to it. (Easily anyway!).
 

Besides considering the amount of available data space, reading the Keil manual will help you a lot. You'll discover, that storage class qualifiers (e.g. idata or xdata) or required to specify the memory area.
 

Hi Thunder,

This buffer is a variable not a constant data. I used it to read IR code once capture. Therefore I have to declare it as a variable. I am confuse as I have written the program and it works will debugger but dont work actually when i burn to my MCU. I suspect that the data memory allocation is wrong for Keil C compiler. Therefore would like to know any setting for Keil C to access the SRAM or my MCU or is there anyway I can declare this variable?

---------- Post added at 16:23 ---------- Previous post was at 16:21 ----------

Hi FvM,

I had read but dont understand the memory allocation therefore would like your advise. And what is idata?
 

And what is idata?
Refer to the Keil C51 manual, chapter Language Extensions, paragraph Memory Areas.

The internal RAM area has to be accessed with xdata qualifier.
As a first attempt, try
Code:
unsigned char xdata Data1[500];
 

Hi FvM,

I did assign unsigned char xdata Data1[500]; can compiler without error. However, once I burn in the Hex file to my MCU, all the data became a constant value which make no changes. I suspect the compiler may have assign this buffer memory to some other places thats which the output is not what I expected

Therefore, I would like to know whether we must set anything in Keil uVision C compiler to use the SRAM of my DS89C450 MCU. I still believe its a setting issue because I debug it using the uVision debugger and my code works fine in the debugging mode
 

xdata usage possibly needs to be setup in target options. Here's how it has to be set for a ADuC836 in µV2. All these things are verbosely discussed in the compiler documentation, just read it.



Generally, the ultimate way to find out what C51 reads into your code is to inspect the compilers list files or the generated assembly code.
 

Hi FvM,

Where can we find Keil uVision compiler documentation? I search around the internet and can only find the quick start guide. Not able to find the documentation that you say discussed on the setting.
 

I guess at keil.com. In earlier days (µVision 2) it was shipped with the compiler.
 

Hi FvM, thanks for your help. I found out that my MCU need to set a bit to use internal SRAM. Now everything is working
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top