Re: Accessing 20-bit memory range - issues with indirect addressing mode

Eric Decker <[email protected]>
Newsgroups gmane.comp.hardware.texas-instruments.msp430.gcc.user
Message-ID <[email protected]>
look at the actual code generated

see what the difference in the actual code is


>From cPhone


> On May 4, 2014, at 1:14 PM, Tomek Lorek <[email protected]> wrote:
> 
> 2014-05-04 22:04 GMT+02:00 Tomek Lorek <[email protected]>:
>> 1. Possibly the main reason my code did not work was using
>> __asm__ __volatile__ ("movx #0, @%0"::"r"(flash));
>> instead of
>> __asm__ __volatile__ ("movx.b %1, @%0":"=r"(flash):"m"(Byte));
>> 
>> But I don't understand why the latter works and the first doesn't (the
>> 1st one causes "tilib: MSP430_State: Internal error (error = 68)" in
>> mspdebug right after stopping the program execution.
> 
> Just checked the flashdump diff right before and after executing the
> program - "movx #0, @%0"::"r"(flash))" variant messed up the flash
> bank A from where I was running the code and it erased 0xc400 instead
> of 0x1c400.
> Do you have any idea why?
> 
> The code is:
> unsigned long flash_addr = 0x1c400;
> unsigned int flash;
> unsigned int sr;
> 
> FCTL3 = FWKEY; // Clear Lock bit
> while (FCTL3 & BUSY) ;
> FCTL1 = FWKEY + MERAS; // Set MERAS bit
> 
> __asm__ __volatile__ ("mov r2,%0":"=r"(sr):);
> _DINT();
> __asm__ __volatile__ ("movx.a %1,%0":"=r"(flash):"m"(flash_addr));
> __asm__ __volatile__ ("movx #0, @%0"::"r"(flash));               // <-
> the line that is under discussion
> 
> __asm__ __volatile__ ("mov r2,%0":"=r"(sr):); // save SR before disabling IRQ
> __dint();
> 
> while (FCTL3 & BUSY) ; // test busy
> FCTL1 = FWKEY; // Clear MERAS bit
> FCTL3 = FWKEY + LOCK; // Set LOCK bit
> 
> ------------------------------------------------------------------------------
> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
> Instantly run your Selenium tests across 300+ browser/OS combos.  Get 
> unparalleled scalability from the best Selenium testing platform available.
> Simple to use. Nothing to install. Get started now for free."
> http://p.sf.net/sfu/SauceLabs
> _______________________________________________
> Mspgcc-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.  Get 
unparalleled scalability from the best Selenium testing platform available.
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.