Discussion in "8051 Discussion Forum" started by    currumblera    Jan 13, 2008.
Sun Jan 13 2008, 04:06 am
#1
hei guys. i m new in this forum. I´m using a MSC1210Y5 (32k flash)from Texas Instruments in my proyect, but i don´t known write c code forr read/write data/program flash. I have partitioned the HCR register for 4K data memory.
Can anyone provide c code that is not the appnotes TI?
I want make a struct config:

struct config
{
unsigned int niMaxPisos; // Numero de pisos (1 a 40)
unsigned int niMaxTiPul; // Maximo tiempo en espera deteccion giro al inicio (0 a 99 dSg)
unsigned int niMinTiPul; // Maximo tiempo en espera deteccion giro durante la marcha (0 a 99 dSg)
unsigned int niNumEntPC; // Numero entradas puertas cerradas (1/2)
unsigned int niTiFiltro; // Tiempo del filtro configurable
};
struct config idata config;

and i want write it in EEprom, modifiing and read later

thaks a lot!
Attachment
Sun Jan 13 2008, 04:21 pm
#2
As per the datasheet.. when you partition the Flash memory, The selected Flash Data memory is added after the 1K SRAM i.e. from 0000 to 03FF (SRAM) and starting from 400H it will be Flash data memory.. which is also accessed through movx routine.
So even though you are writing in flash.. in program you access flash just like any other RAM.

can you explain me about this.. with comments in english..
struct config
{
unsigned int niMaxPisos; // Numero de pisos (1 a 40)
unsigned int niMaxTiPul; // Maximo tiempo en espera deteccion giro al inicio (0 a 99 dSg)
unsigned int niMinTiPul; // Maximo tiempo en espera deteccion giro durante la marcha (0 a 99 dSg)
unsigned int niNumEntPC; // Numero entradas puertas cerradas (1/2)
unsigned int niTiFiltro; // Tiempo del filtro configurable
};


Also explain me more about what you are doing in your project..
Sun Jan 13 2008, 05:49 pm
#3
thaks for your reply, Ajay. My English is not good, sorry.
The project is a worklift, lift, elevator..It has a 7 segment, 4digit LCD, 2 push buttons (+, - or press both for config), and I/O´s for control (run, stop, plant, upper, lower, door closed...). I want weighing in the same project too.

struct config
{
unsigned int niMaxPisos; // Number of plants (1-40)
unsigned int niMaxTiPul; // Max time for waiting (0 to 99 dSg)
unsigned int niMinTiPul; // Max time for run (0 to 99 dSg)
unsigned int niNumEntPC; // input number of closed doors (1/2)
unsigned int niTiFiltro; // Configured filter time
};

If you see my full code project, i have tried read/write, but i don´t known....

if you can help me.......

Sun Jan 13 2008, 10:53 pm
#4
you might only want to store the data of config in flash.. am i right? You have partitioned flash memory as 18K Program and 4K data so starting from address 400H your Flash data memory starts.. you can make use of _at_ compiler directive to store the config structure on flash area of data memory..
the architecture of MSC1210 is little complex..
The files you attached are from your project? then you are already using ROM routines... they should work...
Sun Jan 13 2008, 10:58 pm
#5
I have defined the struct with idata:
struct config
{
unsigned int niMaxPisos; // Numero de pisos (1 a 40)
unsigned int niMaxTiPul; // Maximo tiempo en espera deteccion giro al inicio (0 a 99 dSg)
unsigned int niMinTiPul; // Maximo tiempo en espera deteccion giro durante la marcha (0 a 99 dSg)
unsigned int niNumEntPC; // Numero entradas puertas cerradas (1/2)
unsigned int niTiFiltro; // Tiempo del filtro configurable
};
struct config idata config;

or i have doind this...struct config xdata config _at_ 0x400;?
thaks again Ajay
Sun Jan 13 2008, 11:35 pm
#6
I am having little contradiction in my mind..
>Flash memory is not so easy to access with movx.. when using flash as data memory.. but still datasheet is saying that.. so it concludes that hardware support writing to flash using movx when configured as data memory.

>ROM routines are for in system application programming or for accessing data/program flash memory...

I want you to write small program just for testing purpose of how this data memory works.. do this..
write a UART program.. to store string at location 400H read the same string and.. display on hyper terminal, this way we can check if a simple movx instruction can read and write to flash memory when configured as data memory.
Sun Jan 13 2008, 11:57 pm
#7

Ajay, I am having little contradiction in my mind also.
i want to saved data when the instrument/equipment is power on (with push buttons), in data memory.
If you see the full code, i had an EEPROM 23lc96 before(and a 87c52 without flash memory and OTP) conected to the P1.4 to P1.7 pins, and i controled the E2PROM with the functions writee2 and reade2.
Now, i want to use the flash memory of the MSC1210 for this purpose.
sbit CS=P1^4; // serial E2PROM
sbit SK=P1^5;
sbit DI=P1^6;
sbit DO=P1^7;

how i can structured the address of my variables of the struct config?. I will try tomorrow. I tell you anything!! bye
Mon Jan 14 2008, 12:01 am
#8
that is what i am saying.. just try if you can directly use the Flash data memory by simply specifying the address.. if it is accessible then you can make use of _at_ compiler directive to declare the structure on specified location in flash data memory..

But to clear all contradictions you need to do tests on flash memory as i explained in my previous posts. I hope you are not having any problem in reading English I am trying to be as simple as possible..
Tue Jan 15 2008, 01:00 am
#9
Don´t worry, Ajay. I read english perfectly, my problem is writing or talking!!

It´s OK!!! i can directly use the data memory specifying the address simply! I test it with serial port & hyperterminal.
Thaks for all again, Ajay. It´s a great forum!!!
Tue Jan 15 2008, 02:24 pm
#10
You are welcome glad i am helpful
we try not to leave any doubt in anyone's mind!!

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

KevinTab
Sun Apr 28 2024, 05:35 am
Tumergix
Sun Apr 28 2024, 12:59 am
StevenDrulk
Sat Apr 27 2024, 08:47 pm
StephenHauct
Sat Apr 27 2024, 09:38 am
Adamsaf
Sat Apr 27 2024, 07:12 am
Robertphype
Sat Apr 27 2024, 12:23 am
ktaletrryp
Fri Apr 26 2024, 10:55 pm
Robertrip
Fri Apr 26 2024, 11:20 am