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.

Writing 16 bit Data to MSP430 Info Memory.

Status
Not open for further replies.

Sedat-G

Newbie level 6
Joined
Aug 5, 2010
Messages
11
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
East Lansing MI
Activity points
1,371
Hello Engineers and Enthusiasts,

I am having trouble with writing 16 bit data to Info memory. For example, I wanna write 16 bit data to Segment D (phy addr. 0x1000) and let's say the data is (unsigned long int DATA) 0x40A9. Then What I read from the memory is:

Phy Addr. => Data
0x1040 => A9
0x1041 => FF (Default Value which means nothing is written.)

What I knew from microcontroller class is if I am writing data to the memory which is greater than 8-bit, the rest of the data is written to next physical address. So can you tell me what I am missing?
 

Hi,

What I knew from microcontroller class is if I am writing data to the memory which is greater than 8-bit, the rest of the data is written to next physical address.
Are you sure? Maybe it will happen in RAM, but probably not in Flash or EEPROM.

To write your 16-bit value (0x40A9), try to convert it into two 8-bit bytes (high byte and low byte) and then write each one in its corresponding address:

1. Write ( 0x40A9 >> 8 ) into 0x1040, so it should write a 0x40.
2. Write 0x40A9 into 0x1041, as only 8-bit bytes are written into memory, only the lower byte 0xA9 will be written into 0x1041.

Regards.
 
  • Like
Reactions: Sedat-G

    Sedat-G

    Points: 2
    Helpful Answer Positive Rating
Hello!

What you say is correct. But depending on the write mode you use, you may write 1 word at a time,
in which case indeed, the rest of the data is also written.
I have no experience in writing in word or long word mode but the user guide says it can be
done. Check SLAU208C page 263.

By the way, just in case because it happened to me: you cannot progress step by step with
the debugger while you write to flash. Write a block, and then check for success or failure.

An just a last point: if you write a word, check about alignment otherwise you may get
inconsistent results.

Dora.

Hi,


Are you sure? Maybe it will happen in RAM, but probably not in Flash or EEPROM.

To write your 16-bit value (0x40A9), try to convert it into two 8-bit bytes (high byte and low byte) and then write each one in its corresponding address:

1. Write ( 0x40A9 >> 8 ) into 0x1040, so it should write a 0x40.
2. Write 0x40A9 into 0x1041, as only 8-bit bytes are written into memory, only the lower byte 0xA9 will be written into 0x1041.

Regards.
 
  • Like
Reactions: Sedat-G

    Sedat-G

    Points: 2
    Helpful Answer Positive Rating
To write your 16-bit value (0x40A9), try to convert it into two 8-bit bytes (high byte and low byte) and then write each one in its corresponding addresses.

I guess if it still does not work, I will create an array so that I can split data in 8- bit packages. Bu the problem is read data is not always 16. Sometimes it is 32-bit.

Anyways thank you guys for your help.

---------- Post added at 22:22 ---------- Previous post was at 22:20 ----------

Hello!

I have no experience in writing in word or long word mode but the user guide says it can be
done. Check SLAU208C page 263.
Dora.

This is also what I see in the user's guide. User guide examples are in assembly language. I am writing my code in C. I supposed the following part of data will be written into next physical address but it didn't work.
 

Ok folks, If someone else is also following this post, I found the mistake that I made:

I created char pointer which was referencing to an integer. I changed the type of my pointer to an int pointer and it worked.... I was thinking that pointer is integer itself even though I created a char pointer so that I would reference it to an int data. How stupid I am...

Thanks a lot guys.....
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top