Difference between revisions of "Chips msp430"
Line 16: | Line 16: | ||
* [http://www.ti.com/lit/gpn/msp430f1611 MSP430x15x, MSP430x16x, MSP430x161x Mixed Signal Microcontroller (Rev. E) (Datasheet)] |
* [http://www.ti.com/lit/gpn/msp430f1611 MSP430x15x, MSP430x16x, MSP430x161x Mixed Signal Microcontroller (Rev. E) (Datasheet)] |
||
* [http://www.ti.com/litv/pdf/slaz018b MSP430F15x/16x/161x Device Erratasheet (Rev. B)] |
* [http://www.ti.com/litv/pdf/slaz018b MSP430F15x/16x/161x Device Erratasheet (Rev. B)] |
||
== Software Notes == |
|||
===Word align requirement === |
|||
Msp430 is a 16-bit processor. Note, that it requires certain 16-bit register and memory transfer operation source also to be 16-bit word aligned in the memory. I.e., the address must be divisible by 2. |
|||
This is easy to miss in C code. for example, the following example is from the real procedure written for msp430 flash memory operations. |
|||
foo() |
|||
{ |
|||
uint8_t aa[20]; |
|||
uint16_t word = 0x1234; |
|||
... |
|||
writeToFlash(address, word); |
|||
printToSerial( *address ); |
|||
... |
|||
} |
|||
In the result we observed that the printout was "1200" - the LSB was lost... |
|||
changing the code to the following fixed the problem: |
|||
... |
|||
uint16_t dummy; |
|||
uint16_t word = 0x1234; |
|||
... |
|||
It might be safer to declare 'word' as static and make sure it is word aligned in the memory. This would also free up the stack. |
|||
On the other hand in some cases automatic word-alignment of 16-bit words might create unexpected surprises. For example, the following structure is really 10 bytes long, instead of 8. This might hurt you if you try to fit it with a packet that has less than 10 bytes for the payload space. |
|||
struct { |
|||
uint16_t w1; |
|||
uint8_t b1; |
|||
uint16_t w2; |
|||
uint8_t b2; |
|||
uint16_t w3; |
|||
}; |
|||
So, watch out! |
Revision as of 22:19, 9 April 2008
MSP430 MCU GCC toolchain can be found here http://mspgcc.sourceforge.net/.
The documentation supplied with mspgcc is very comprehensive and describes the MCU in great detail. Can be found here http://mspgcc.sourceforge.net/manual/. This could be very good introductory material for this MCU.
Tmote Sky sensor module is equipped with MSP430 F1611 MCU. According to mspgcc docs on how to decode MSP430 part numbers (http://mspgcc.sourceforge.net/manual/x675.html).
F1611 - stands for:
- F - Flash ROM,
- 16xx - Like 14x, but adding 2xDAC12, 3xDMA, brownout reset and I2C,
- xx11 - 48K ROM, 10K RAM
Manufacturers page for this MCU - http://focus.ti.com/docs/prod/folders/print/msp430f1611.html.
Key documents about this MCU:
- MSP430F15x/16x/161x MSP430x1xx Family User's Guide (Rev. F)
- MSP430x15x, MSP430x16x, MSP430x161x Mixed Signal Microcontroller (Rev. E) (Datasheet)
- MSP430F15x/16x/161x Device Erratasheet (Rev. B)
Software Notes
Word align requirement
Msp430 is a 16-bit processor. Note, that it requires certain 16-bit register and memory transfer operation source also to be 16-bit word aligned in the memory. I.e., the address must be divisible by 2.
This is easy to miss in C code. for example, the following example is from the real procedure written for msp430 flash memory operations.
foo() { uint8_t aa[20]; uint16_t word = 0x1234; ... writeToFlash(address, word); printToSerial( *address ); ... }
In the result we observed that the printout was "1200" - the LSB was lost...
changing the code to the following fixed the problem:
... uint16_t dummy; uint16_t word = 0x1234; ...
It might be safer to declare 'word' as static and make sure it is word aligned in the memory. This would also free up the stack.
On the other hand in some cases automatic word-alignment of 16-bit words might create unexpected surprises. For example, the following structure is really 10 bytes long, instead of 8. This might hurt you if you try to fit it with a packet that has less than 10 bytes for the payload space.
struct { uint16_t w1; uint8_t b1; uint16_t w2; uint8_t b2; uint16_t w3; };
So, watch out!