Hi Alex
The MSP430s I've seen only have 16kB of RAM in the first 64kB, and of course
you cannot just write to flash with a simple "mov".
However, the TI sample code for the MSP430x5438 Experimenter board has an
example of recoding audio to flash. You may have a look there although their
code uses IAR which supports 20 bit addresses in general.
Here's a working FlashReadByte(), which somebody on this list showed me a some
time before.
Best
Matthias
uint8_t FlashReadByte (uint32_t addr){
uint8_t result;
uint32_t register sr, flash;
__asm__ __volatile__ (
"mov r2 , %1 \n"
"bic %3 , r2 \n"
"nop \n"
"movx.a %4 , %2 \n"
"movx.b @%2, %0 \n"
"mov %1 , r2 \n"
:"=X"(result),"=r"(sr),"=r"(flash)
:"i"(GIE),"m"(addr));
return result;
}
On 05.08.2011, at 23:39, Alex Stefan wrote:
> Does anybody have some example routines for reading/writing to high addresses
> in
> the flash?
>
> This is what I've written so far, but it's far from a working version:
>
> static inline __attribute__((always_inline)) void
> flash_write_byte(uint32_t addr, uint8_t val)
> {
>
> __asm__ __volatile__ (
> "dint \n"
> "nop \n"
> "mova %[addr], r15 \n"
> "movx %[val], @r15 \n"
> "eint \n"
> :
> :[addr] "r"(addr), [val] "m"(val)
> );
> }
> static inline __attribute__((always_inline)) uint8_t
> flash_read_byte(uint32_t addr)
> {
>
> uint8_t result;
> __asm__ __volatile__ (
> "dint \n"
> "nop \n"
> "mova %[addr], r15 \n"
> "movx @r15, %[result] \n"
> "eint \n"
> :[result] "=m"(result)
> :[addr] "r"(addr)
> );
> return result;
> }
>
> The problem, from what I could tell, comes from the inlining of the functions
> and the way the compiler generates their prologue. It would help me very much
> if
> I had fully working example to start from.
>
> Alex
>
>
> ------------------------------------------------------------------------------
> BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
> The must-attend event for mobile developers. Connect with experts.
> Get tools for creating Super Apps. See the latest technologies.
> Sessions, hands-on labs, demos & much more. Register early & save!
> http://p.sf.net/sfu/rim-blackberry-1
> _______________________________________________
> Mspgcc-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users
------------------------------------------------------------------------------
BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts.
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
Mspgcc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users