Jump to content
Soumit

How to input a 64bit value from stack to one of the MSP430f5529 registers?

Recommended Posts

Hello,

I wrote a code for calculating VCO frequency and divider values for a PLL from the given output frequencies. For now I am printing the values in the console to debug my code and it is working properly. But now I want to move the values from stack to registers available in MSP430f5529. In the image below you can see that freq_VCO value is stored in stack memory location 0x04382. How do I move this value in one of the registers?

Pleas help!

image.thumb.png.6af9633a77ca530a363326376dfa7e18.png

Share this post


Link to post
Share on other sites

The '5529 is a 16-bit device, with 16-bit registers, so it's not possible to use a single register to store a 64-bit value. Perhaps storing the address of the 64-bit value?  But I don't see any real rationale for doing that...  Others, far smarter than I, may offer better suggestions.

Share this post


Link to post
Share on other sites

Thank you for your reply. Perhaps yes, it is not possible to store a 64-bit value in 1 register. But I can store in split registers i guess. I just don't know how to do such a thing. If any ideas please help.

Share this post


Link to post
Share on other sites
22 hours ago, NurseBob said:

The '5529 is a 16-bit device, with 16-bit registers, so it's not possible to use a single register to store a 64-bit value. Perhaps storing the address of the 64-bit value?  But I don't see any real rationale for doing that...  Others, far smarter than I, may offer better suggestions.

No, 5529 is not 16-bit device. It is with CPUvX2 that have 20-bit registers and 20-bit assembler instructions. Some of this instructions (so called address instructions) can be executed in one cycle. BTW, also, all FRAM devices are with 20-bit registers and 20-bit assembler instructions. 

Share this post


Link to post
Share on other sites

From assembler it can be seen as 16 or 20bit depending on the instruction set used - MSP430 or MSP430X, it has a 16/20bit ALU. I would guess a C-compiler will mix 16/20bit style instructions for speed if memory requirement is > 64K.

The OP never mentioned if using C or assembler and what the value is needed for - printing? a calculation? store somewhere else (in a "variable")?.

To load a 64bit value from consecutive words in memory into registers from assembler code register indirect adressing mode with auto increment is the easiest. Move the stack pointer into a register and add (or subtract?) the offset needed to reach the data and use it as the base (assuming the data lives in a stack frame with a fixed offset from the current stack pointer value).

From C code use the * dereference operator to read from an address into a variable. It may be possible to read the data into separate registers from C as 16 bit values, but then you are at the mercy of the compiler. I have not looked into how to get at the stack pointer from C, doable? Use a global variable instead of picking it off the stack?

A final note: I do not understand why loading into register(s) is required...

Share this post


Link to post
Share on other sites

Thank you all for your responses!!

@ Terjeio,

I am using C and the value I need to store in split registers so that when I connect a synthesizer I can feed the value to it for further actions. I am not sure if the value is stored in stack memory will I be able to retrieve it later as the compiler stores at random address?? Therefore i thought of storing it in registers of the MSP430 so that i can access the value for later purpose.

As #Agaelema mentioned I used a pointer to receive the address of the 64bit variable and increment it to read all the address.

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...