[Tinyos-help] TelosB (MSP430) cannot address Words at odd memory locations
Faisal Aslam
aslam at informatik.uni-freiburg.de
Fri May 22 02:18:48 PDT 2009
Dear all,
We have written a Java Virtual Machine (JVM) that works fine on AVR
(i.e. mica2/micaz/cricket) platforms.
However, the same code does not work on Telosb (i.e MSP430).
The MSP430 can only address words (16Bit) at even addresses, Bytes
(8Bit) can be addressed at every address.
This is documented in the msp-gcc documentation as well as in the mcu
datasheet from TI.
http://mspgcc.sourceforge.net/manual/x214.html
http://mspgcc.sourceforge.net/manual/x987.html
http://focus.ti.com/lit/ug/slau049f/slau049f.pdf (Chapter 1.4.5, 3.2.1)
We have tried -mstrict-align flag with msp430-gcc compiler however; it
does not change any thing.
We have a solution to this problem but that is not very good solution
and will reduce performance.
Is there anyone who has solution for this and has encounter the same
problem?
Looking forward for your reply.
Faisal
PS: See the sample code below of one simple example of the problem.
********************************************************
module BlinkC @safe()
{
uses interface Leds;
uses interface Boot;
}
implementation
{
void Ourtest();
event void Boot.booted()
{
call Leds.led0On();
Ourtest();
}
void Ourtest() {
uint8_t v[] = {0x11,0x22,0x33,0x44};
uint16_t* v16;
v16 = (uint16_t*)(v+1); //an odd address
*v16 = 0x6655;
//expected result:
// v = {0x11,0x55,0x66,0x44}
//wrong output:
// v = {0x55,0x66,0x33,0x44}
if (v[0] == 0x11) {
call Leds.led1On(); //should On 1st LED
} else if (v[0] == 0x55) {
call Leds.led2On(); //however, this (wrong) else is executed
}
}
}
More information about the Tinyos-help
mailing list