This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Baby steps with MSP programming

Other Parts Discussed in Thread: MSP430F5529

Hey

I am a newbie with the MSP430 with no background about programming microcontrollers. I read and tried to study from existing examples but it doesn't work for me,  I have lots of difficulties and was hoping for someone to help and guide me. Just to be clear, I know what I need to do but I dont know how to do it...

My project is to build a compass using the MSP430F5529 and the HMC5883L. I connected the P3.0 pin to the SDA of the HMC and P3.1 to the SCL.

The first thing that I want to do is  to configure the HMC registers,the problem is  that I have only one pin that transferring data and I want to transfer through it a word and not bit by bit, for example :

WDTCTL = WDTPW + WDTHOLD;     //disabling watchdog

P3DIR |= BIT0;  //P3.0 output direction

P3OUT=0x3C 0x00 0x68; // writing in register A of magnetometer

the 0x3C is the write command to the slave device, the 0x00 is the register number of the slave, and 0x68 is what i want to write in the specific register.

I pretty sure the above is wrong, so if someone can help me with my first step that would be great !

thank you

  • It's a I2C device, so you should not bit-bang a pin trying to send it bytes as I don't think it will make it easier to understand or to code it.
    So look for i2c examples in F5529  tool and software folder.http://www.ti.com/lit/zip/slac300

  • First step would be learning i2c. Then you shall read about i2c peripheral of your chip, then source code examples of i2c.

    To be honest - seeing your level of knowledge I would suggest to put compass project aside and start new one, blinking LED project.

  • You can't write a byte to P3OUT and have it sent serially through I2C to the device. P3 is an 8-bit wider digital I/O port. Writing 0x3c to it will set 4 lines to high and 4 lines to low (if they are set to output). Each bit in P3OUT (as well as in P3DIR etc.) refers to a different digital I/O pin.

    The F5529 has an USCIB module that can do all the I2C communication. You should use it instead. The 5x family users guide will tell you how to use the different hardware modules (it explains all modules in any 5x family device, so check the device datasheet which ones are available for your MSP)
    I recommend reading the chapter about the clock system, digital I/O (also includes port pin configuration) and the USCI.

    However, you should be aware that I2C uses an open-collector method. So no peer ever pulls the lines high, they need to be pulled high by an external pull-up resistor of 10k or less. The internal ones are too weak for I2C.
    There are demo codes available for I2C, but I don't like demo codes, except for very, very good documented ones (which you won't find often). They usually only show a working example but do not explain why it works and how you could use it for something else than just this exact example. So they are more like 'proof of concept' codes than anything educationally valuable.
  • You may want to check out the MSP Design Workshop as a way of getting started with your MSP430F5529 microcontroller. This class starts out with the "blinking LED" project, but takes you through many of the MSP peripherals.
    processors.wiki.ti.com/.../MSP_Design_Workshop

    The workshop doesn't cover I2C, yet. For that - and learning about the MSP430 in general - I really like the following book:

    MSP430 Microcontroller Basics
    John Davies
    www.amazon.com/.../ref=sr_1_2;qid=1432841454&sr=8-2&keywords=getting+started+with+msp430

    This is an excellent book. Sure, it's a little bit dated, but the content is worth taking your time to read.

    Scott

**Attention** This is a public forum