Jump to content
Sign in to follow this  
LIJsselstein

[SOLVED] Assembler Error: odd operand: 6229

Recommended Posts

I ran into this error while developing a reasonably large application using Energia-1.6.10E18. The minimal code to producing this error is below:

 

File: Someheader.h

#ifndef __SOMEHEADER#define __SOMEHEADER// Infomem address for the correction factor. This factor is two bytes long.#define INFOMEM_CORRECTION_FACTOR 0x1855// Read a value from infomem. If not between min and max, return standard valuetemplate <typename T>T readInfomemValueLimit(T min, T max, T* address, T stdValue){  if (*address < min || *address > max ){    return stdValue;  }  return *address;}#endif
Sketch:
#include <Wire.h>#include "someheader.h"// Calculate the measurement interval based on messages per day, and the time correctionuint32_t applyCorrection(uint16_t value){  uint16_t temp = 1;  // Get the correction factor from information memory and make sure it is within specified bounds  uint16_t correctionFactor = readInfomemValueLimit((uint16_t)0, (uint16_t)20000, (uint16_t *)(INFOMEM_CORRECTION_FACTOR), (uint16_t)10000);  return (uint32_t)((uint16_t)temp * (uint16_t)correctionFactor);}void setup() { }void loop() {  //uint16_t someValue = 1;  //uint32_t correctedValue;  //correctedValue = applyCorrection(someValue);}
The compilation output is:

C:\energia-1.6.10E18\arduino-builder -dump-prefs -logger=machine -hardware "C:\energia-1.6.10E18\hardware" -tools "C:\energia-1.6.10E18\tools-builder" -tools "C:\energia-1.6.10E18\hardware\tools\msp430" -built-in-libraries "C:\energia-1.6.10E18\libraries" -libraries "C:\Energia\libraries" -fqbn=energia:msp430:MSP-EXP430G2553LP -ide-version=10610 -build-path "C:\Users\LIJSSE~1\AppData\Local\Temp\build251f882e875a4832b4dad2f88cd38085.tmp" -warnings=more -prefs=build.warn_data_percentage=75 -verbose "C:\Energia\test_struct\test_struct.ino"

C:\energia-1.6.10E18\arduino-builder -compile -logger=machine -hardware "C:\energia-1.6.10E18\hardware" -tools "C:\energia-1.6.10E18\tools-builder" -tools "C:\energia-1.6.10E18\hardware\tools\msp430" -built-in-libraries "C:\energia-1.6.10E18\libraries" -libraries "C:\Energia\libraries" -fqbn=energia:msp430:MSP-EXP430G2553LP -ide-version=10610 -build-path "C:\Users\LIJSSE~1\AppData\Local\Temp\build251f882e875a4832b4dad2f88cd38085.tmp" -warnings=more -prefs=build.warn_data_percentage=75 -verbose "C:\Energia\test_struct\test_struct.ino"

Using board 'MSP-EXP430G2553LP' from platform in folder: C:\energia-1.6.10E18\hardware\energia\msp430

Using core 'msp430' from platform in folder: C:\energia-1.6.10E18\hardware\energia\msp430

Detecting libraries used...

"C:\energia-1.6.10E18\hardware\tools\msp430/bin/msp430-g++" -c -g -O2 -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -E -CC -mmcu=msp430g2553 -DF_CPU=16000000L -DARDUINO=10610 -DENERGIA=10610 -DENERGIA_MSP-EXP430G2553LP -DENERGIA_ARCH_MSP430 -IC:\energia-1.6.10E18\hardware\tools\msp430/include "-IC:\energia-1.6.10E18\hardware\energia\msp430\cores\msp430" "-IC:\energia-1.6.10E18\hardware\energia\msp430\variants\MSP-EXP430G2553LP" "C:\Users\LIJSSE~1\AppData\Local\Temp\build251f882e875a4832b4dad2f88cd38085.tmp\sketch\test_struct.ino.cpp" -o "nul"

"C:\energia-1.6.10E18\hardware\tools\msp430/bin/msp430-g++" -c -g -O2 -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -E -CC -mmcu=msp430g2553 -DF_CPU=16000000L -DARDUINO=10610 -DENERGIA=10610 -DENERGIA_MSP-EXP430G2553LP -DENERGIA_ARCH_MSP430 -IC:\energia-1.6.10E18\hardware\tools\msp430/include "-IC:\energia-1.6.10E18\hardware\energia\msp430\cores\msp430" "-IC:\energia-1.6.10E18\hardware\energia\msp430\variants\MSP-EXP430G2553LP" "C:\Users\LIJSSE~1\AppData\Local\Temp\build251f882e875a4832b4dad2f88cd38085.tmp\sketch\test_struct.ino.cpp" -o "nul"

Generating function prototypes...

"C:\energia-1.6.10E18\hardware\tools\msp430/bin/msp430-g++" -c -g -O2 -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -w -x c++ -E -CC -mmcu=msp430g2553 -DF_CPU=16000000L -DARDUINO=10610 -DENERGIA=10610 -DENERGIA_MSP-EXP430G2553LP -DENERGIA_ARCH_MSP430 -IC:\energia-1.6.10E18\hardware\tools\msp430/include "-IC:\energia-1.6.10E18\hardware\energia\msp430\cores\msp430" "-IC:\energia-1.6.10E18\hardware\energia\msp430\variants\MSP-EXP430G2553LP" "C:\Users\LIJSSE~1\AppData\Local\Temp\build251f882e875a4832b4dad2f88cd38085.tmp\sketch\test_struct.ino.cpp" -o "C:\Users\LIJSSE~1\AppData\Local\Temp\build251f882e875a4832b4dad2f88cd38085.tmp\preproc\ctags_target_for_gcc_minus_e.cpp"

"C:\energia-1.6.10E18\tools-builder\ctags\5.8-arduino10/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\LIJSSE~1\AppData\Local\Temp\build251f882e875a4832b4dad2f88cd38085.tmp\preproc\ctags_target_for_gcc_minus_e.cpp"

Compiling sketch...

"C:\energia-1.6.10E18\hardware\tools\msp430/bin/msp430-g++" -c -g -O2 -Wall -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=msp430g2553 -DF_CPU=16000000L -DARDUINO=10610 -DENERGIA=10610 -DENERGIA_MSP-EXP430G2553LP -DENERGIA_ARCH_MSP430 -IC:\energia-1.6.10E18\hardware\tools\msp430/include "-IC:\energia-1.6.10E18\hardware\energia\msp430\cores\msp430" "-IC:\energia-1.6.10E18\hardware\energia\msp430\variants\MSP-EXP430G2553LP" "C:\Users\LIJSSE~1\AppData\Local\Temp\build251f882e875a4832b4dad2f88cd38085.tmp\sketch\test_struct.ino.cpp" -o "C:\Users\LIJSSE~1\AppData\Local\Temp\build251f882e875a4832b4dad2f88cd38085.tmp\sketch\test_struct.ino.cpp.o"

<command-line>:0:12: warning: missing whitespace after the macro name [enabled by default]

 

C:\Users\LIJSSE~1\AppData\Local\Temp\cc9RPlUb.s: Assembler messages:

 

C:\Users\LIJSSE~1\AppData\Local\Temp\cc9RPlUb.s:24: Error: odd operand: 6229

 

exit status 1

Error compiling for board MSP-EXP430G2553LP.

The compiler error is is triggered in the line "return (uint32_t)((uint16_t)temp * (uint16_t)correctionFactor);", if you replace the variable correctionFactor with a constant (e.g. 1) then the sketch compiles successfully. The target doesn't seem to matter, the above is for the Launchpad but compiling for my own board with MSP430FR2433 gives the same error.

 

Any ideas why this happens?

Share this post


Link to post
Share on other sites

To answer my own question: the error is triggered because, for 16 or 32 bit operations, the variable must be aligned on an even memory address, however the INFOMEM_CORRECTION_VALUE variable was defined on an odd address. Moving it from 0x1855 to 0x1856 solved the compiler error.

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.

Sign in to follow this  

×
×
  • Create New...