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.

UART with Launchpad and CCS

Other Parts Discussed in Thread: ENERGIA

Hello everyone!

I'm beginner with MPS430  and I want to make a serial communication in UART mode using my launchpad. My objective: Turn on/off three leds and reads one-wire temperature with DS18B20 one-wire thermometer. I don't know how to do it but I was reading the TI example for UART

Somebody could explain me in which manner I can use this piece of code to achieve my objective?

http://pastebin.com/4ysVX8iT

Thanks for your help

  • Juan David Bola��os Aguilar said:
    I'm beginner with MPS430  

    From the question, it sounds rather like you are not just a beginner with the MSP430, but a beginner with microcontrollers in general - is that right?

    Do you have prior experience in any form of programming? Do you have experience with 'C' programming in particular?

    Juan David Bola��os Aguilar said:
    I'm beginner

    So let's begin at the beginning.

    Basic foundations that you need for working with small microcontrollers like the MSP430 are:

    http://bit.ly/T6pTIA

    You will also need an understanding of the specific details of the particular microcontroller you're using; MSP430 in this case:

     You will find links to the Family User Guide and Device Datasheet on the Product page for the specific chip you're using (you didn't mention it).

    Juan David Bola��os Aguilar said:
     I want to make a serial communication in UART mode using my launchpad. My objective: Turn on/off three leds and reads one-wire temperature with DS18B20 one-wire thermometer.

    The first thing you need to learn - for any project in any domain - is to break down your requirement into "sub-systems". In your case, three sub-systems are immediately obvious:

    1. Control LEDs;
    2. UART serial comms;
    3. Interface with DS18B20.

    Each of  the first two is a pretty standard "first steps" project for starting with any microcontroller. Therefore I suggest that you proceed as follows:

    1. Create a project to blink an LED.
      Sounds trivial, but covers an awful lot of stuff that you'll need: writing code; configuring stuff, using IO, using the using the tools; downloading to the target; etc.
       
    2. Practice using the debugger to see how this simple program runs.
      Debugging is an essential part of any form of development, and the debugger is an essential tool for microcontroller projects. The sooner you learn to use it, the better...
       
    3. Extend the project to send a fixed "Hello, World" string out of the UART. Start by polling the status registers, then move on to interrupt-driven...
       
    4. Extend the project to send variable information out of the UART. eg, the state of a switch
       
    5. Extend the project to receive information from the UART. Have it echo the received characters back to the sender - to confirm that it's working
      Continue practicing with the debugger - use breakpoints to see when characters arrive, and when they are transmitted. Learn to manually modify the the received value, so that the "echo" is a different character.
       
    6. Extend the project to interpret the information from the UART. So that you can send serial "commands" to turn the LEDs on & off.

    You see how this builds, step-by-step, towards your goal?

    http://e2e.ti.com/support/microcontrollers/msp430/f/166/p/262106/917022.aspx#917022

    Interfacing with the DS18B20 is a significantly more involved task. You will need to study the DS18B20 datasheet and associated 1-WireTM protocol documentation to understand its operation & communication requirements...

    General approach to interfacing: http://www.8052.com/forum/read/160143

     

  • I gave a detailed reply - it is currently stuck in Moderation.

  • Meanwhile, here's the two key documents on the Maxim (formerly Dallas) 1-WireTM protocol which you will need to study carefully:

    http://www.8052.com/forum/read/149007 - includes links to the complete 1-WireTM protocol documentation set.

    You will, of course, also need to carefully study the DS18B20 datasheet

  • Thanks you so much Andy. I can see your reply in my email inbox. 


    From the question, it sounds rather like you are not just a beginner with the MSP430, but a beginner with microcontrollers in general - is that right?

    Thats right, I'm beginner with microcontrollers in general but I have some good backgrounds in C and made some projects. This is my first piece of code: 


    http://pastebin.com/q4JR7hDk

    Works fine!

     
    The first thing you need to learn - for any project in any domain - is to break down your requirement into "sub-systems". In your case, three sub-systems are immediately obvious:
    1. Control LEDs;
    2. UART serial comms;
    3. Interface with DS18B20.


    Well, I'm controlling my three LEDS with push buttons. Now I need to understand how can I use the USART to make a serial communication in UART mode.  In the example provided by TI use the TIMER_A but I dont understand nothing about that, but They said that's a Full duplex Communication which is great. I've made serial communication with Energia and python

    http://pastebin.com/F9HQtA6r

    I want to make something like that but using C

    Again, Thank you so much for your kind help friend. 

  • Hi Sir

    You can start form the example code with hyperterminal or tera term.

    Revise the code with your function.

     

    #include <msp430g2553.h>
    
    #ifndef TIMER0_A1_VECTOR
    #define TIMER0_A1_VECTOR    TIMERA1_VECTOR
    #define TIMER0_A0_VECTOR    TIMERA0_VECTOR
    #endif
    
    volatile long tempRaw;
    
    void FaultRoutine(void);
    
    void main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;            // Stop watchdog timer
    
      P1DIR = 0x41;                        // P1.0 & 6 output (red/green LEDs)
      P1OUT = 0;                           // LEDs off
    
    if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF)
       FaultRoutine();		               // If calibration data is erased
     				                       // run FaultRoutine()
      BCSCTL1 = CALBC1_1MHZ; 		       // Set range
      DCOCTL = CALDCO_1MHZ;  		       // Set DCO step + modulation
    
      BCSCTL3 |= LFXT1S_2;                 // LFXT1 = VLO
      IFG1 &= ~OFIFG;                      // Clear OSCFault flag
      BCSCTL2 |= SELM_0 + DIVM_3 + DIVS_3; // @@MCLK = DCO/8
    
      while(1)
      {
    	ADC10CTL1 = INCH_10 + ADC10DIV_0;  // Temp Sensor ADC10CLK
    	ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON;
    	/* VR+ = VREF+ and VR- = AVSS */
    	/* 64 x ADC10CLKs */
    
    	_delay_cycles(5);                  // Wait for ADC Ref to settle
    	ADC10CTL0 |= ENC + ADC10SC;        // Sampling and conversion start
    	/* ADC10 Enable Conversion */
    	/* ADC10 Start Conversion */
    
        P1OUT = 0x40; 			    	   // green LED on
        _delay_cycles(100);
    
        ADC10CTL0 &= ~ENC;
        ADC10CTL0 &= ~(REFON + ADC10ON);
        tempRaw = ADC10MEM;
    
    
        P1OUT = 0; 		                   // green LED off
        _delay_cycles(125000);			   // @@125,000 cycles. 1sec turn on
      }
    }
    
    void FaultRoutine(void)
    {
    	P1OUT = 0x01;                       // red LED on
    	while(1); 			               // TRAP
    }
    

    Try to use it.

    Best Regards,

**Attention** This is a public forum