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.

MSP430 Launchpad

Other Parts Discussed in Thread: MSP430G2231, TUSB3410

hello,

 

I am new to launch pad... when i got the kit i tried that inbuilt code, the leds glow as required but nothing on the screen of hyper terminal except a list of "??????".

 

Now, when i am finished trying some other codes for leds and switches, they worked well but when i tried to debug that demo code using IAR, it gives an error while linking........

The error is as mentioned:-

Building configuration: lp - Debug 

Updating build tree... 

main.c  

Warning[Pa082]: undefined behavior: the order of volatile accesses is undefined in this statement C:\Documents and Settings\x0137852\Desktop\launchpad\main.c 232 

Linking 

Error[e104]: Failed to fit all segments into specified ranges. Problem discovered in segment CODE. Unable to place 22 block(s) (0x4b6 byte(s) total) in  

0x3c8 byte(s) of memory. The problem occurred while processing the segment placement command "-P(CODE)CODE=FC00-FFDF", where at the  

moment of placement the available memory ranges were "CODE:fc18-ffdf" 

Error while running Linker 

 

Total number of errors: 1 

Total number of warnings: 1 

Kindly suggest me some solution to this.
kindly also help me for the fact why nothing displays on hyperterminal.............?
waiting for reply
Thanking you

  • The Compiler Warning[Pa082] is just silly. Ignore it.

    The Linker Error[e104] is caused by the size of the code the Compiler generated was to big for the chip you specified in the IAR Project. It looks like you specified a chip with only 1KB of Main Flash while the compiled code needs over 1 KB. Try a chip with at least 2 KB of Main Flash.

    The demo program is flaky. And PC interface hardware may have problem too. I do not have any LaunchPad (yet).

  • qwert,

    could you make sure that you have the correct device (G2231) selected? The error indicates that the selected device only has ~0x3C8 or ~1000 bytes of flash, from 0xFC00-0xFFFF. The G2231 has 2KB of flash, which would be sufficient for the firmware.

     

    The default demo application sends the temperature reading in Fahrenheit to the UART. Depending on the device, the room temperature reading could vary in the 60-80 degree range. This, translated to ASCII values, should appear as some kind of alphabet character in HyperTerminal. I would recommend trying the GUI to display the data, or using a more flexible terminal software such as HTerm to display values in Hex/Decimal.

    Regards,

    Dung

     

  • qwert said:
    Warning[Pa082]: undefined behavior: the order of volatile accesses is undefined in this statement C:\Documents and Settings\x0137852\Desktop\launchpad\main.c 232 

    Would you mind posting the source line in question too?
    If not, all I can say is that this error means that the order of volatile accesses is undefined in this statement.

    qwert said:
    Failed to fit all segments into specified ranges. Problem discovered in segment CODE. Unable to place 22 block(s) (0x4b6 byte(s) total) in  0x3c8 byte(s) of memory.

    Let me make an educated guess: the compiler is unable to squeeze 1206 bytes of code into the available 968 bytes of flash memory? I believe, the compiler is right. I'd have problems too.
    In other words: your code is too large for the 1kb (minus variable initializers and interrupt vector table) flash the processor has.

    qwert said:
    Kindly suggest me some solution to this.

    Try reducing the code size or buy a larger processor.

    qwert said:
    kindly also help me for the fact why nothing displays on hyperterminal.............?


    Let me look into my crystal orb... Well, I don't see anything, so what about this answer:
    'the computer is off'
    Doesn't fit? Wait, I'll ask my Tarot cards. Let's see... 'the fool'. Well, this could mean
    'HyperTerm isn't running"
    Still no go? Hmm, well, my dices tell me to try this answer:
    "the driver for the virtual COM port isn't installed"

    Enough guessing wihtout any information. If it still doesn't work, you have two choices: seach the forum for already given answers (there are SEVERAL threads about LaunchPad and HyperTerm in this forum) or provide some detailed information.

  • Jens-Michael,

    You overlooked the last part of the original posting. It says: nothing displays on hyperterminal....except a list of "??????"

    It is quite possible that the temperature was 63 degrees F.

    --OCY

  • You got it OCY.

    Rubbing the chip with your finger will change the reading.

  • eltury,

     

    rubbing the chip doesn't show any change of values except that it only indicates a change in the led's glowing as according to the coding and the GUI that is available on net is not working here on my PC.

     

  •  

    thank you Dung and everyone for their help.....

     

    It worked and even i could find the ASCII values on the hyper terminal that show the temp to vary between 60 t0 83 degree fahrenheit. But GUI doesn't work, when i try to run the "EXE" file dialog box appears saying could not find the main class and the setup exits.

     

    Anyhow, i have got the values in ASCII so not a big problem....

     

    Now, everyone..... Kindly suggest me some more projects so as to make me play with this small launch pad..... i have done all the led blinking using interrupt, timer , switches...... all that stuff......

     

    kindly suggest me something more good and difficult to play with...

     

    thank you all once again....

  • Hi qwert,

    if your looking for 'something more good and difficult to play with' I suggest to have a look at the girls next door! That's more fun than playing around with MCUs *lol*.

    Have a look at TIs application notes (http://focus.ti.com/mcu/docs/mcuprodtechdoc.tsp?sectionId=95&tabId=1202&familyId=342&techDoc=1&docCategoryId=1&viewType=mostrecent) if you don't have own ideas what to do with an MCU. Maybe this will point you into the right direction.

    Rgds
    aBUGSworstnightmare

  • hey aBUGSworstnightmare,

     

    i already had a look at your so called suggestion. Anyhow, thanks for the information.

     

    I am planning to work on a MORSE CODE decoder using this launchpad. Do you have any ideas or suggestions so as to guide me in the RIGHT direction?

  • Morse decoding is easy in a way, and hard in a way. The easy part is that there are no particularly complex algorithms involved, and you only need minimal microcontroller resources -- chiefly the adc converter. The hard part is that the signal has very few definite parameters of modulation or form, so your implementation must be very generic such that it will be insensitive to all the variables and unknowns about the modulation. The baseband and broadband frequencies are unknown. The frequencies are prone to drifting. There may be lots of noise of various sorts. The received signal amplitude is prone to fading / fluctuation. The timing of the modulation is unknown and could vary over more than a 10:1 range. The most helpful advice I can give is as follows: A: Get the MSP430 to sequentially sample a signal on the desired analog input pin at some reasonable rate such as 11kHz or 22kHz. This will be the input signal you need to analyze. B: Make some kind of input coupling circuit so that your input audio or other signal can be coupled to the MSP430 ADC converter input so that you get the right level of gain/loss, low pass filtering before the ADC, et. al. C: Implement the actual morse decoder algorithm in C on a PC using initial data inputs that are either recorded samples from the PC's sound card or which are simulated data sets (write a program to output samples of morse code with a test message given some particular modulation speed and baseband frequency). Generate the audio samples at a sampling rate similar to what you expect to use on the MSP430. Once you have the prerecorded / pre-generated test messages decoding properly using the C code on the PC, make or acquire some new samples to test with -- ones which have different frequencies, different amplitudes, more noise, more frequency/timing variation et. al. Get those to decode, and then you just port the code to the MSP430 which will be easy enough if you've written the code such that it is easily ported which should not be hard since it must only access RAM buffer arrays, variables, and some reference tables about the morse alphabet itself. Use only 'unsigned short' or 'unsigned char' fixed point types which are 8 or 16 bits in the code / data, and keep in mind you'll only have a hundred or so bytes of RAM for all variables and signal storage. The first thing you'll need is basically an energy detector which is like a VU meter, feed it any signal of any frequency or waveform and it will calculate the average energy of that signal over some short period of time such as 5ms or so. This can be done by just calculating the RMS or root mean square of the series of samples such as PowerAccumulator += (Sample - 32767)^2 assuming your samples are originally unsigned 0...65536 range numbers. If they're already signed 16 bit quantities, don't subtract 32767. Anyway do that in a loop over the right number of samples, say, 20 at a time to generate your average. Since your power accumulator variable is possibly only 16 bits, you may need to prevent overflow of its range somehow such as: PowerAccumulator += (Sample >> 8) * (Sample >> 8) or whatever which divides the input samples before their squaring/summing by dropping the least significant 8 bits and shifting the rest of the bits downward so 0x7f00 would become 0x007f though the problem with that is that extremely quiet signals which only have the least significant few bits active may be ignored. So then you have a power variable that measures the loudness (well power anyway) of the signal over a short time with no respect for the actual frequency or waveform. You could skip the square root in the RMS since your squared variable is still a fine representation of the power. Then you will need some kind of threshold power to say that power levels greater than X volume/signal power are considered "audio present" and anything quieter is "audio absent" . The most basic way is to hard code the number which is the threshold of "quiet" versus "audio" but you could make the threshold adaptive over a period of time such as 1/10th second or 1 second or 10 seconds or whatever so that you're better able to adapt to quiet or loud signals automatically. You could also use this adaptive signal level value over some long time to scale the incoming ADC samples themselves so that you have less overflow or undersensitivity problems during the above signal power measurement process. That loop of averaging the signal power over a modestly long while and adjusting the gain of the receiver and the noise 'squelch' level would be basically an AGC or variable squelch type of operation. Anyway eventually you'll end up with a set of averages like so where 'A' is "AUDIO detected at a volume more than the threshold" and 'Q' is "Quiet below the threshold": QQQQQQQQAAAAAAQQQQQQAAAAAAQQQQQQAAAAAAQQQQQQAAAQQQQQQAAAQQQQQQAAAQQQQQQAAAAAAQQQQQQAAAAAAQQQQQQAAAAAAQQQQQQQQQ and if you look at the "ON", "OFF" periods over that set of data you'll eventually see you have a message of a series of morse coded letters. To decode that of course you'll want to have a loop that looks at the timing of the shortest bursts of audio (above that would be three unit intevals as in 'AAA'), and dynamically sets that value as your 'dot' threshold timing. Also look for the longest bursts of audio, much longer than the 'dot' duration, and set that interval as the 'dash' time you're looking for. Make the timing re-adjust every few seconds to adapt to variable rates. So then you scan the power detector's output for sequences of "DOT" long audio or sequences of "DASH" length audio and you can then generate a "." or "-" output once you've decided which length the most recent audio burst corresponded to, short or long. Now you have a sequence of dot and dash sequences output from this stage of processing, and you can just compare them to the alphabet tables to see at what point you have decoded a whole letter. When deciding where a letter starts and stops of course you should look for extra long quiet time preceding the first letter in a series and look for the maximum possible length letter you could make from a sequence of input so that you don't assume too early the end of a letter and the start of the next one. The limited RAM will cause you to not keep too long of a history of past data streams of history of quiet versus not quiet, but that is OK since if you have the power averaging timing windows set to a reasonable length, only a few dozen outputs of that data would correspond to even the longest letter, and you could really discard the data as soon as you've determined whether a given audio burst is a dot or a dash so you wouldn't even need more than a few samples to discriminate the dot vs dash timing.
  • yup, Thanks for such a helpful suggestion....

     

    1.one thing i would like to ask is that before applying the input signal to ADC of  MSP430, is it better to use a tone decoder  based on PLL or something so as to get good results or just an amplification with the band pass limiting is enough.

     

    2. other thing how much flash would be the minimum requirement so as to fit in the database to identify the morse code from an audio signal?

     

  • old cow yellow said:
    You overlooked the last part of the original posting.

    No, I overlooked the fist part and only replied to the question at the end "why nothing displays on hyper terminal" :)
    I'm sorry, I was already tired of those many 'help me but I don't tell with what' and 'make my job for me' and non-MSP questions :)

    A list of ??? seems to indicate a wrong baudrate setting if it cannot be explaind by the output itself (binary degree value)
    Yet the question mark has teh ASCII value of 63 and this fits into the expected range of room temperature in Fahrenheit .

    Oh, and the compiler warning is not necessarily silly.
    It is possible that the order of accesses to different volatile variables is not expressed by the code, often by missing brackets, so the compilers choice of interpreting a formula or expression does not necessarily match the order the programmer intended or assumed. It may or may not have side-effects and teh compiler cannot know. So it issues a warning.
    Without the source line, nobody can tell.

    quert said:
    2. other thing how much flash would be the minimum requirement so as to fit in the database to identify the morse code from an audio signal?

    In theory, for the original morse code (letter a-z only), 17 bytes are necessary. Each letter requires 2 bits for the length and up to 4 bits for the code itself.
    I guess reserving one byte per letter (including the length info) is a bit less code-consuming and will allow numbers too (then 3 bit length as numbers are 5 blips), making 26/36 bytes. For the complete extended alphabet, each sign may be up to 8 blips at varying length, so a larger table is necessary.
    What you really need depends on how good your algorithm is at identifying the blips and separating the individual signs. How much you want to calculate and how much to pick from a fixed predefined table.

     

  • There is no point to use a tone decoder / PLL either in front of the ADC or after the ADC via software. The only use of a tone decoder is if you have a pure tone of a known frequency to detect, and with morse it might not be that at all, though I suppose in the simplest cases you could have something close to a pure tone but then you would need to tune the receiver so that the tone frequency was in the capture band of the PLL/tone decoder and that is an unnecessary complication / restriction anyway. I'd look at adding an AGC or level compressor type of circuit much more so than any kind of tone decoder, however the ADC has a fairly good dynamic range so if your receiver has any kind of reasonable RF AGC / squelch settings, I suspect you'll already get a reasonable level signal into the ADC with respect to the dynamic range of loudest possible audio vs softest useful audio level above the noise floor. Thus you could probably just go straight into the ADC through maybe a buffer amp / limiter if that is needed just to get the audio dynamic range to something like 1V or 2V peak-to-peak or whatever the ADC will like. A low pass filter will be desirable any time you ADC a signal, though in this case fidelity of the waveform is not really a concern, so really a lowpass or bandpass is mostly to limit adjacent channel interference for selectivity reasons rather than worrying about the quality of the sampled signal since fidelity will not help demodulation unless you do use tone detectors. In fact if you just amplify anything significantly above the noise floor so that it is clipped / limited to a binary level "1 = audio, 0 = not" that could even be sampled by a GPIO input instead of the ADC and you would get the same useful information for decoding as by using the ADC. Clipping to the VCC and GND rails to prevent overshoots with schottky diodes is highly recommended unless you know your input signal will never go beyond the power voltages of the MSP either way. If you implemented an interval power averaging circuit (VU meter like) circuit followed by a threshold detector that would eliminate much of the preprocessing on the MSP and then you'd just be doing on/off pattern recognition to identify symbols. You could implement the symbol decoder with the right finite state machine which would basically implement a parser algorithm that detects any possible morse letter or gives a framing error state which could help reset the decoder (or just long silence instead) in case the decoding fails due to noise or decoder mistake or such. There are lots of parser generator programs out there that can generate a matching parser code for any given alphabet / symbol sequence input, though I don't know of any that would likely output concise / efficient enough C code to run directly on a small MSP430 variant, though I'm sure somewhere there is a parser to FSM generator you could use. Not that it would be hard to write the parser by hand since there are only a few dozen possible characters to detect.
  • hey ,

     

    I want to use UART feature on launch pad to enter the text to be transmitted via serial and even need to echo the text on the screen. what you suggest, can i do it with G2231?

     

    or tell me can i use F2274 chip on launchpad as it also supports spy bi wire communication?

     

     

  • oh sorry , 

     

    i discovered that f2274 is not available in DIp package.... so suggest me something so as i can get the characters from keyboard and further use my operations....

  • The G2xx1 chips included in the LaunchPad kit can use so-called "Timer UART". Use 1MHz (not 1MHz/8) as timer clock and you can get up to 9600 b/s.

  • Hi,

    what about using something like this: http://www.nkcelectronics.com/tssop-to-dip-adapter-28pin-065mm-28065.html ? Ideal for prototyping ;o)!

    Rgds
    aBUGSworstnightmare

  • hey,

     

    TIMER UART is fine. i am not getting how to do transmission frm keyboard to microcontroler using this....

    Please suggest me how should i proceed.

    this is the demo code which i tried after changing the header files and all but it doen't seem working.

    #define RXD       0x02                      // RXD on P1.1

    #define TXD       0x20                      // TXD on P1.5


    //   Conditions for 2400 Baud SW UART, ACLK = 32768


    #define Bitime_5  0x06                      // ~ 0.5 bit length + small adjustment

    #define Bitime    0x0E                      // 427us bit length ~ 2341 baud


    unsigned int RXTXData;

    unsigned char BitCnt;


    void TX_Byte (void);

    void RX_Ready (void);


    //  M. Buccini / L. Westlund

    //  Texas Instruments Inc.

    //  October 2005

    //  Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.40A

    //******************************************************************************


    #include  <msp430x20x3.h>



    void main (void)

    {

      WDTCTL = WDTPW + WDTHOLD;                 // Stop watchdog timer

      CCTL0 = OUT;                              // TXD Idle as Mark

      TACTL = TASSEL_1 + MC_2;                  // ACLK, continuous mode

      P1SEL = TXD + RXD;                        //

      P1DIR = TXD;                              //


    // Mainloop

      for (;;)

      {

      RX_Ready();                               // UART ready to RX one Byte

      _BIS_SR(LPM3_bits + GIE);                 // Enter LPM3 w/ interr until char RXed

      TX_Byte();                                // TX Back RXed Byte Received

      }

    }



    // Function Transmits Character from RXTXData Buffer

    void TX_Byte (void)

    {

      BitCnt = 0xA;                             // Load Bit counter, 8data + ST/SP

      while (CCR0 != TAR)                       // Prevent async capture

        CCR0 = TAR;                             // Current state of TA counter

      CCR0 += Bitime;                           // Some time till first bit

      RXTXData |= 0x100;                        // Add mark stop bit to RXTXData

      RXTXData = RXTXData << 1;                 // Add space start bit

      CCTL0 =  CCIS0 + OUTMOD0 + CCIE;          // TXD = mark = idle

      while ( CCTL0 & CCIE );                   // Wait for TX completion

    }



    // Function Readies UART to Receive Character into RXTXData Buffer

    void RX_Ready (void)

    {

      BitCnt = 0x8;                             // Load Bit counter

      CCTL0 = SCS + OUTMOD0 + CM1 + CAP + CCIE;   // Sync, Neg Edge, Cap

    }


    // Timer A0 interrupt service routine

    #pragma vector=TIMERA0_VECTOR

    __interrupt void Timer_A (void)

    {

      CCR0 += Bitime;                           // Add Offset to CCR0


    // TX

      if (CCTL0 & CCIS0)                        // TX on CCI0B?

      {

        if ( BitCnt == 0)

        CCTL0 &= ~ CCIE;                        // All bits TXed, disable interrupt

        else

        {

          CCTL0 |=  OUTMOD2;                    // TX Space

          if (RXTXData & 0x01)

          CCTL0 &= ~ OUTMOD2;                   // TX Mark

          RXTXData = RXTXData >> 1;

          BitCnt --;

        }

      }

    // RX

      else

      {

        if( CCTL0 & CAP )                       // Capture mode = start bit edge

        {

        CCTL0 &= ~ CAP;                         // Switch from capture to compare mode

        CCR0 += Bitime_5;

        }

        else

        {

        RXTXData = RXTXData >> 1;

          if (CCTL0 & SCCI)                     // Get bit waiting in receive latch

          RXTXData |= 0x80;

          BitCnt --;                            // All bits RXed?

          if ( BitCnt == 0)

    //>>>>>>>>>> Decode of Received Byte Here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

          {

          CCTL0 &= ~ CCIE;                      // All bits RXed, disable interrupt

          _BIC_SR_IRQ(LPM3_bits);               // Clear LPM3 bits from 0(SR)

          }

    //>>>>>>>>>> Decode of Received Byte Here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        }

      }

    }

     

    suggest me something.

     

    thanks

  • qwert said:

    #define RXD       0x02                      // RXD on P1.1

    #define TXD       0x20                      // TXD on P1.5

     

    P1.5 does not have any connection to the emulation part (from the Launchpad schematic) , so you can not use it to transfer unless you make a wire connection from P1.5 to the RX pin. Try pin P1.2 to see. I have not look all the code but that's the start.

    Regards,

  • hey , 

     

    i mentioned i made these general changes .....

     

  • lol, I though that was the code after changing... not the original one.

    For transferring directly from the attached MSP chip, I do not think the Launchpad does the job. Since there are no connection direct from F2xxx to TUSB. However, there are connections between F2xxx -> F1612 ->TUSB through BTXD and BRXD pins. I am not sure the purposes of those pins, since the F1612 only need to uses SBWTCK and SBWTDIO to debug and program for F2xxx. I do not have the F1612 firmware so I dont know how it handles the data if it is transferred from F2xxx through P1.2 and P1.1.

    Can anyone tell me what those pins P1.2 and P1.1 for? Should it be used to directly transfer data from F2xxx to the PC with the F1612 as a buffer/bridge? Are those pins intended for engineers who wants to modify/play around the launchpad? I think of it because the Launchpad has TPx (x=1-7, JTAG connections) pins which allows you to program the F1612  which means TI tells you "Let's modify this to something you want!!!". If they do not want you to modify/play around with the Launchpad, they wont make those pins, am I right?

    I am also doing the transferring stuff using the Launchpad, but I am doing it in hard way, and still learning how to do that. Currently, I am able to make F1612 communicate with the PC through TUSB.

    Regards,

  • Nogcas said:
    Can anyone tell me what those pins P1.2 and P1.1 for?

    It is possible that these pins are for accessing the F2xx bootstrap loader (through software UART). The 1612 can act as a PC (forward the communitcation from PC to these pins as if it were a normal RS232) and trigger the BSL process.

    Just an idea.

  • Look at the included source code for the reference temperature measurement application.  It uses a software UART on the MSP430G2231 out through P1.2, P1.1

    to send the temperature sensor data from the MSP430G2231 out through the J3 jumper to BRXD (P1.1), BTXD (P1.2) into the MSP430F16x  on the emulator interface but also

    into the TUSB3410 USB to serial chip via BRXDI, BTXDI inputs on the TUSB's P3.0, P3.1 since the labels BRXDI and BTXDI on the schematic page for the TUSB match

    the labels on the MSP430F16x schematic page the signals are connected to both the TUSB and the F16x.

    I don't know exactly what the F16x does with the serial UART data, maybe it can be BSLed or maybe it uses it to receive programming data blocks from the PC so

    the F16x can use the data to implement the SBW protocol to generate SBWTDIO/SBWTCK to program the MSP430 in the socket.

     

     

    [QUOTE]

    Pre-programmed Demo Application - Internal Temperature Measurement


    LaunchPad includes a pre-programmed MSP430G2231 device. Once LaunchPad is connected via USB, the demo will start an LED toggle sequence. Pressing button P1.3 will start the Temperature Measurement mode.

    A reference temperature is measured at the beginning of this mode, and can be re-calibrated with another button press on P1.3. LaunchPad signals a rising or falling temperature by varying the brightness of the on-board red or green LED, respectively. Temperature data is also communicated via back-channel UART through USB to the PC, which can be displayed using the provided GUI or a terminal on the PC.

    This demo application is using the on-chip peripherals of the MSP430G2231 device, such as the 10-bit ADC to sample the internal temperature sensor and 16-bit timers, which drive the PWM to vary brightness of the LEDs and enable a software UART for communication with the PC.

  • The User's Guide (slau318) says:

    1.1 Overview
    ... It also provides a 9600-Baud UART serial connection from the MSP430G2xx device to the host PC or a connected target board. ...

    MSP-EXP430G2 LaunchPad features:
    • USB debugging and programming interface featuring a driverless installation and application UART serial communication with up to 9600 Baud

    This is referring to BTXD-P1.2 and BRXD-P1.1. These pins and connections are not used by the FET but can be used by the "application" of the target. The preloaded "application" is using one of them the send temperature readings to the PC. But it did not try to receive anything from the PC.

    The code quoted by qwert should work after the correct changes are made.

    G2xx1 does not have BSL. Anybody interested in writing a small BSL for G2xx1 and/or F20xx?

     

  • hey, 

     

    the code that i posted is not working even after making the necessary changes .... i am mentioning the changed code below: -

     

    #define RXD       0x04                      

    #define TXD       0x02                      


    //   Conditions for 2400 Baud SW UART, ACLK = 32768


    #define Bitime_5  0x06                      // ~ 0.5 bit length + small adjustment

    #define Bitime    0x0E                      // 427us bit length ~ 2341 baud


    unsigned int RXTXData;

    unsigned char BitCnt;


    void TX_Byte (void);

    void RX_Ready (void);




    #include  <msp430g2231.h>



    void main (void)

    {

      WDTCTL = WDTPW + WDTHOLD;                 // Stop watchdog timer

      P1DIR |= 0x01 + 0x40;

      CCTL0 = OUT;                              // TXD Idle as Mark

      TACTL = TASSEL_2 + MC_2 + ID_3;                  // ACLK, continuous mode

      P1SEL = TXD + RXD;                        //

      P1DIR = TXD;                              //


    // Mainloop

      for (;;)

      {

      RX_Ready();                               // UART ready to RX one Byte

      _BIS_SR(LPM3_bits + GIE);                 // Enter LPM3 w/ interr until char RXed

      TX_Byte();                                // TX Back RXed Byte Received

      }

    }



    // Function Transmits Character from RXTXData Buffer

    void TX_Byte (void)

    {

      BitCnt = 0xA;                             // Load Bit counter, 8data + ST/SP

      while (CCR0 != TAR)                       // Prevent async capture

        CCR0 = TAR;                             // Current state of TA counter

      CCR0 += Bitime;                           // Some time till first bit

      RXTXData |= 0x100;                        // Add mark stop bit to RXTXData

      RXTXData = RXTXData << 1;                 // Add space start bit

      CCTL0 =  CCIS0 + OUTMOD0 + CCIE;          // TXD = mark = idle

      while ( CCTL0 & CCIE );                   // Wait for TX completion

    }



    // Function Readies UART to Receive Character into RXTXData Buffer

    void RX_Ready (void)

    {

      BitCnt = 0x8;                             // Load Bit counter

      CCTL0 = SCS + OUTMOD0 + CM1 + CAP + CCIE;   // Sync, Neg Edge, Cap

    }


    // Timer A0 interrupt service routine

    #pragma vector=TIMERA0_VECTOR

    __interrupt void Timer_A (void)

    {

      CCR0 += Bitime;                           // Add Offset to CCR0


    // TX

      if (CCTL0 & CCIS0)                        // TX on CCI0B?

      {

        if ( BitCnt == 0)

        CCTL0 &= ~ CCIE;                        // All bits TXed, disable interrupt

        else

        {

          CCTL0 |=  OUTMOD2;                    // TX Space

          P1OUT ^= 0x40;

          if (RXTXData & 0x01)

          CCTL0 &= ~ OUTMOD2;                   // TX Mark

          RXTXData = RXTXData >> 1;

          BitCnt --;

        }

      }

    // RX

      else

      {

        if( CCTL0 & CAP )                       // Capture mode = start bit edge

        {

        CCTL0 &= ~ CAP;                         // Switch from capture to compare mode

        CCR0 += Bitime_5;

        P1OUT ^= 0x01;

        }

        else

        {

        RXTXData = RXTXData >> 1;

          if (CCTL0 & SCCI)                     // Get bit waiting in receive latch

          RXTXData |= 0x80;

          BitCnt --;                            // All bits RXed?

          if ( BitCnt == 0)

    //>>>>>>>>>> Decode of Received Byte Here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

          {

          CCTL0 &= ~ CCIE;                      // All bits RXed, disable interrupt

          _BIC_SR_IRQ(LPM3_bits);               // Clear LPM3 bits from 0(SR)

          }

        }

      }

    }

    but it is not working yet...........
     hey help me doing this...
    and one more thing also tell me what mode should be used to put in the character for echoing.... i have tried Putty.exe also but no results.
    so suggest me if there is some other way out......
    waiting for a positive response....

  • hey, 

     

    the code that i posted is not working even after making the necessary changes .... i am mentioning the changed code below: -

     

     

    #define RXD       0x04                      

    #define TXD       0x02                      


    //   Conditions for 2400 Baud SW UART, ACLK = 32768


    #define Bitime_5  0x06                      // ~ 0.5 bit length + small adjustment

    #define Bitime    0x0E                      // 427us bit length ~ 2341 baud


    unsigned int RXTXData;

    unsigned char BitCnt;


    void TX_Byte (void);

    void RX_Ready (void);




    #include  <msp430g2231.h>



    void main (void)

    {

      WDTCTL = WDTPW + WDTHOLD;                 // Stop watchdog timer

      P1DIR |= 0x01 + 0x40;

      CCTL0 = OUT;                              // TXD Idle as Mark

      TACTL = TASSEL_2 + MC_2 + ID_3;                  // ACLK, continuous mode

      P1SEL = TXD + RXD;                        //

      P1DIR = TXD;                              //


    // Mainloop

      for (;;)

      {

      RX_Ready();                               // UART ready to RX one Byte

      _BIS_SR(LPM3_bits + GIE);                 // Enter LPM3 w/ interr until char RXed

      TX_Byte();                                // TX Back RXed Byte Received

      }

    }



    // Function Transmits Character from RXTXData Buffer

    void TX_Byte (void)

    {

      BitCnt = 0xA;                             // Load Bit counter, 8data + ST/SP

      while (CCR0 != TAR)                       // Prevent async capture

        CCR0 = TAR;                             // Current state of TA counter

      CCR0 += Bitime;                           // Some time till first bit

      RXTXData |= 0x100;                        // Add mark stop bit to RXTXData

      RXTXData = RXTXData << 1;                 // Add space start bit

      CCTL0 =  CCIS0 + OUTMOD0 + CCIE;          // TXD = mark = idle

      while ( CCTL0 & CCIE );                   // Wait for TX completion

    }



    // Function Readies UART to Receive Character into RXTXData Buffer

    void RX_Ready (void)

    {

      BitCnt = 0x8;                             // Load Bit counter

      CCTL0 = SCS + OUTMOD0 + CM1 + CAP + CCIE;   // Sync, Neg Edge, Cap

    }


    // Timer A0 interrupt service routine

    #pragma vector=TIMERA0_VECTOR

    __interrupt void Timer_A (void)

    {

      CCR0 += Bitime;                           // Add Offset to CCR0


    // TX

      if (CCTL0 & CCIS0)                        // TX on CCI0B?

      {

        if ( BitCnt == 0)

        CCTL0 &= ~ CCIE;                        // All bits TXed, disable interrupt

        else

        {

          CCTL0 |=  OUTMOD2;                    // TX Space

          P1OUT ^= 0x40;

          if (RXTXData & 0x01)

          CCTL0 &= ~ OUTMOD2;                   // TX Mark

          RXTXData = RXTXData >> 1;

          BitCnt --;

        }

      }

    // RX

      else

      {

        if( CCTL0 & CAP )                       // Capture mode = start bit edge

        {

        CCTL0 &= ~ CAP;                         // Switch from capture to compare mode

        CCR0 += Bitime_5;

        P1OUT ^= 0x01;

        }

        else

        {

        RXTXData = RXTXData >> 1;

          if (CCTL0 & SCCI)                     // Get bit waiting in receive latch

          RXTXData |= 0x80;

          BitCnt --;                            // All bits RXed?

          if ( BitCnt == 0)

    //>>>>>>>>>> Decode of Received Byte Here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

          {

          CCTL0 &= ~ CCIE;                      // All bits RXed, disable interrupt

          _BIC_SR_IRQ(LPM3_bits);               // Clear LPM3 bits from 0(SR)

          }

        }

      }

    }

    but it is not working yet...........
     hey help me doing this...
    and one more thing also tell me what mode should be used to put in the character for echoing.... i have tried Putty.exe also but no results.
    so suggest me if there is some other way out......
    waiting for a positive response....

  • Hi qwert,

    you are trying to use an external 32kHz crystal, right? Is the crystal soldered on the pad Q1 correctly? You can use the included crystal from Micro Crystal for this. You also need to configure your clock module to use the external input as ACLK.

    Easiest thing is to use the LaunchPad demo application with the internal calibrated 1MHz DCO. This will not need any external components.

  • ok if i go for using that demo application . can you just suggest me how to go for receiver part using that application...... kindly put in the code for receiver function that can be used with that demo.............

     

    waiting...........

  • Hi,

    here is a slightly modified Timer interrupt function. I've not tested it, but it should work.  You have to add some variables to the demo as well to control the RX flow and store the incoming data.

    if (timerMode == TIMER_UART_MODE)
      {
        CCR0 += Bitime;                           // Add Offset to CCR0 
        if (CCTL0 & CCIS0)                        // TX on CCI0B?
        {
          if ( BitCnt == 0)
            CCTL0 &= ~ CCIE;                        // All bits TXed, disable interrupt
          else
          {
            CCTL0 |=  OUTMOD2;                    // TX Space
            if (TXByte & 0x01)
            CCTL0 &= ~ OUTMOD2;                   // TX Mark
            TXByte = TXByte >> 1;
            BitCnt --;
          }
        }
        else
        {
     if( CCTL0 & CAP )                       // Capture mode = start bit edge

        {

        CCTL0 &= ~ CAP;                         // Switch from capture to compare mode

        CCR0 += Bitime_5;

        P1OUT ^= 0x01;

        }
        else
        {
          RXTXData = RXTXData >> 1;
            if (CCTL0 & SCCI)                   // Get bit waiting in receive latch
              RXTXData |= 0x80;
            BitCnt --;                            // All bits RXed?
            if ( BitCnt == 0)
    //>>>>>>>>>> Decode of Received Byte Here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            {
            CCTL0 &= ~ CCIE;                      // All bits RXed, disable interrupt
            _BIC_SR_IRQ(LPM3_bits);               // Clear LPM3 bits from 0(SR)

            }
          }
        }
      }

    Try using the debugger to get your code running, timer UART communication is always a little bit tricky and the debuggin will screew up the timing ,but you should see the rigth data comming in.

     

    Best Regards

    Eric

  • Hi,

    I am not really understand the following code:in

    TX_Byte()

    {...
    CTTL0=CCIS0 + OUTMOD0 + CCIE;
    ...
    }
    As I understand here is the TXD will be in COMPARE mode + output mode: SET + Interrupt Enable <=> Take input signal at TXD pin in compare mode and output "1" at the TXD pin.
    Does the code make the TXD pin as INPUT and OUTPUT at the same time? And what does it COMPARE? Does it make the output of TXD pin exactly as CCI input? I dont understand the CCI input here...

    Also, according the diagram in TIMER_A block diagram, the CCI2A and CCI2B are actually (physical) input pins. But there is an output OUT2 Signal at the same pin also. I am confusing... Can anyone please explain about CCI and compare mode, there is not much in the user guide.

    And one quick question: Are the SIN and SOUT pins of TUSB always High = 1? I suppose so cause the start bit should be 0 so when idle they are 1, am I right?

    Best Regards,

  • Nogcas said:
    Also, according the diagram in TIMER_A block diagram, the CCI2A and CCI2B are actually (physical) input pins. But there is an output OUT2 Signal at the same pin also.

    Don't confuse physical pins ans logical signals.

    While CCI2A is a logical signal which is an input and can be derived from a pin, teh very same physical pin can also be the output of a completely different signal.

    It is even possible to set the pin state by using the GPIO module (using PxDIR.y=1 and PxOUT.y=z) and cause a reaction on the attached module that uses this pin as input signal.

    There are only a few cases where the inputs are disconnected from the pin. Using the port mapping controller or for some pins with analog function on some devices (to avoid parasitic influences).

    Nogcas said:
    And what does it COMPARE

    Compare means comparing the CCR register content against the timer value. This normally means to do an action after a certain time has passed. In this case: switch the output to the next TX bit level and throw an interrupt so the CCR can be prepared for the overnext bit level.

  • hey ERIC,

     

    i have tried using that demo program. I am very much successfull in sending a data mentioned in program to make it appear on hyper terminal screen. 

     

    but to transfer a character from keyboard to the microcontroller is a task that i am not getting how to do?

     

    Can you help me regarding that ? i am posting my code till not .... it is the modification of demo code.

     

     

     

    #include  "msp430x20x2.h"


    #define     LED0                  BIT0

    #define     LED1                  BIT6

    #define     LED_DIR               P1DIR

    #define     LED_OUT               P1OUT



     

    #define     BUTTON                BIT3

    #define     BUTTON_OUT            P1OUT

    #define     BUTTON_DIR            P1DIR

    #define     BUTTON_IN             P1IN

    #define     BUTTON_IE             P1IE

    #define     BUTTON_IES            P1IES

    #define     BUTTON_IFG            P1IFG

    #define     BUTTON_REN            P1REN


    #define     TXD                   BIT1                      // TXD on P1.1

    #define     RXD                   BIT2                      // RXD on P1.2


    #define     APP_STANDBY_MODE      0

    #define     APP_APPLICATION_MODE  1


    #define     TIMER_PWM_MODE        0   

    #define     TIMER_UART_MODE       1







    //   Conditions for 9600/4=2400 Baud SW UART, SMCLK = 1MHz

    #define     Bitime_5              0x05*4                      // ~ 0.5 bit length + small adjustment

    #define     Bitime                13*4//0x0D    

     

    #define     UART_UPDATE_INTERVAL  1000



    unsigned char BitCnt;



    unsigned char applicationMode = APP_STANDBY_MODE;


    unsigned int TXByte;

    void InitializeLeds(void);

    void InitializeButton(void);

    void PreApplicationMode(void);                     // Blinks LED, waits for button press

    void ConfigureTimerUart(void);  

    void Transmit(void);

    void InitializeClocks(void);


    void main(void)

    {

      

        WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT

      

      InitializeClocks();

      InitializeButton();

      InitializeLeds();

      PreApplicationMode();                     // Blinks LEDs, waits for button press

      

      /* Application Mode begins */

      applicationMode = APP_APPLICATION_MODE;

      

        

      __enable_interrupt();                     // Enable interrupts.

      

      

      /* Main Application Loop */

      while(1)

      {    

         __bis_SR_register(CPUOFF + GIE);        // LPM0 with interrupts enabled

          ConfigureTimerUart();

            TXByte = 95;                       // A character with high value, outside of temp range 

            Transmit();

            

          TXByte = (unsigned char)( 85);      

          Transmit(); 

        

          

        }

        

      }   

    void PreApplicationMode(void)

    {    

      LED_DIR |= LED0 + LED1;

      LED_OUT |= LED0;                          // To enable the LED toggling effect

      LED_OUT &= ~LED1;

        

      BCSCTL1 |= DIVA_1;                        // ACLK/2

      BCSCTL3 |= LFXT1S_2;                      // ACLK = VLO

      

      TACCR0 = 1200;                             //   

      TACTL = TASSEL_1 | MC_1;                  // TACLK = SMCLK, Up mode.  

      TACCTL1 = CCIE + OUTMOD_3;                // TACCTL1 Capture Compare

      TACCR1 = 600;  

      __bis_SR_register(LPM3_bits + GIE);          // LPM0 with interrupts enabled

    }





    void ConfigureTimerUart(void)

    {

      CCTL0 = OUT;                               // TXD Idle as Mark

      TACTL = TASSEL_2 + MC_2 + ID_3;            // SMCLK/8, continuous mode

      P1SEL |= TXD + RXD;                        //

      P1DIR |= TXD;                              //  

    }




    // Function Transmits Character from TXByte 

    void Transmit()

      BitCnt = 0xA;                             // Load Bit counter, 8data + ST/SP

      while (CCR0 != TAR)                       // Prevent async capture

        CCR0 = TAR;                             // Current state of TA counter

      CCR0 += Bitime;                     // Some time till first bit

      TXByte |= 0x100;                        // Add mark stop bit to TXByte

      TXByte = TXByte << 1;                 // Add space start bit

      CCTL0 =  CCIS0 + OUTMOD0 + CCIE;          // TXD = mark = idle

      while ( CCTL0 & CCIE );                   // Wait for TX completion

    }




    // Timer A0 interrupt service routine

    #pragma vector=TIMERA0_VECTOR

    __interrupt void Timer_A (void)

    {

     

        CCR0 += Bitime;                           // Add Offset to CCR0  

        if (CCTL0 & CCIS0)                        // TX on CCI0B?

        {

          if ( BitCnt == 0)

            CCTL0 &= ~ CCIE;                        // All bits TXed, disable interrupt

          else

          {

            CCTL0 |=  OUTMOD2;                    // TX Space

            if (TXByte & 0x01)

            CCTL0 &= ~ OUTMOD2;                   // TX Mark

            TXByte = TXByte >> 1;

            BitCnt --;

          }

        }

      }




    #pragma vector=TIMERA1_VECTOR

    __interrupt void ta1_isr(void)

    {

      TACCTL1 &= ~CCIFG;

      if (applicationMode == APP_APPLICATION_MODE)

        LED_OUT &= ~(LED0 + LED1);

      else

        LED_OUT ^= (LED0 + LED1);

        

    }




    void InitializeClocks(void)

    {


      BCSCTL1 = CALBC1_1MHZ;                    // Set range

      DCOCTL = CALDCO_1MHZ;

      BCSCTL2 &= ~(DIVS_3);                         // SMCLK = DCO / 8 = 1MHz  

    }




    void InitializeButton(void)                 // Configure Push Button 

    {

      BUTTON_DIR &= ~BUTTON;

      BUTTON_OUT |= BUTTON;

      BUTTON_REN |= BUTTON;

      BUTTON_IES |= BUTTON;

      BUTTON_IFG &= ~BUTTON;

      BUTTON_IE |= BUTTON;

    }




    void InitializeLeds(void)

    {

      LED_DIR |= LED0 + LED1;                          

      LED_OUT &= ~(LED0 + LED1);  

    }


    /* *************************************************************

     * Port Interrupt for Button Press 

     * 1. During standby mode: to exit and enter application mode

     * 2. During application mode: to recalibrate temp sensor 

     * *********************************************************** */

    #pragma vector=PORT1_VECTOR

    __interrupt void PORT1_ISR(void)

    {   

        BUTTON_IFG = 0;  

        BUTTON_IE &= ~BUTTON;            /* Debounce */

      WDTCTL = WDT_ADLY_250;

      IFG1 &= ~WDTIFG;                 /* clear interrupt flag */

      IE1 |= WDTIE;  

       

         applicationMode = APP_APPLICATION_MODE; // Switch from STANDBY to APPLICATION MODE

        __bic_SR_register_on_exit(LPM3_bits);        

         

    }


    #pragma vector=WDT_VECTOR

    __interrupt void WDT_ISR(void)

    {

        IE1 &= ~WDTIE;                   /* disable interrupt */

       IFG1 &= ~WDTIFG;                 /* clear interrupt flag */

       WDTCTL = WDTPW + WDTHOLD;        /* put WDT back in hold state */

        BUTTON_IE |= BUTTON;             /* Debouncing complete */

    }

     

     

     

    so please tell me how should i receive a character through keyboard?

     

    regards,

     

  • Hi,

    the receiving should be handled inside the TimerA0 interrupt handler. Try to add the code i posted earlier into the interrupt handler, as i said before you just have to take care about the Data and Flow control.

    The basic ides behind that is that you need a function which is looking at the input pin with the correct timing and add the single bits to one data value. The TimerA0 handler is executed if the device is trying to send a byte and you should use the same function for receiving. Just activate the function when you receive a incoming start sequence and test the input pin on every interrupt. Everything else is already in place.

  • hello

     

    i am using the following code to displaying characters on screen for 11 times or so... but it is giving garbage values ...

    why so ?

     

     

    #include  "msp430x20x2.h"


    #define     LED0                  BIT0

    #define     LED1                  BIT6

    #define     LED_DIR               P1DIR

    #define     LED_OUT               P1OUT



     

    #define     BUTTON                BIT3

    #define     BUTTON_OUT            P1OUT

    #define     BUTTON_DIR            P1DIR

    #define     BUTTON_IN             P1IN

    #define     BUTTON_IE             P1IE

    #define     BUTTON_IES            P1IES

    #define     BUTTON_IFG            P1IFG

    #define     BUTTON_REN            P1REN


    #define     TXD                   BIT1                      // TXD on P1.1

    #define     RXD                   BIT2                      // RXD on P1.2


    #define     APP_STANDBY_MODE      0

    #define     APP_APPLICATION_MODE  1


    #define     TIMER_PWM_MODE        0   

    #define     TIMER_UART_MODE       1







    //   Conditions for 9600/4=2400 Baud SW UART, SMCLK = 1MHz

    #define     Bitime_5              0x05*4                      // ~ 0.5 bit length + small adjustment

    #define     Bitime                13*4//0x0D    

     

    #define     UART_UPDATE_INTERVAL  1000



    unsigned char BitCnt;



    unsigned char applicationMode = APP_STANDBY_MODE;


    unsigned int TXByte;

    //void InitializeLeds(void);

    //void InitializeButton(void);

    //void PreApplicationMode(void);                     // Blinks LED, waits for button press

    void ConfigureTimerUart(void);  

    void Transmit(void);

    //void InitializeClocks(void);


    void main(void)

    {

      

        WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT

      

      //InitializeClocks();

      //InitializeButton();

      //InitializeLeds();

      //PreApplicationMode();                     // Blinks LEDs, waits for button press

      

      /* Application Mode begins */

      applicationMode = APP_APPLICATION_MODE;

      

        

      __enable_interrupt();                     // Enable interrupts.

      

      

      /* Main Application Loop */

      //while(1)

      for(int i=0;i<=10;i++)

      {    

        // __bis_SR_register(CPUOFF + GIE);        // LPM0 with interrupts enabled

          ConfigureTimerUart();

            TXByte = 95;                       // A character with high value, outside of temp range 

            Transmit();

            

          TXByte = (unsigned char)( 75);      

          Transmit(); 

        

          

        }

        

      }   





    void ConfigureTimerUart(void)

    {

      CCTL0 = OUT;                               // TXD Idle as Mark

      TACTL = TASSEL_2 + MC_2 + ID_3;            // SMCLK/8, continuous mode

      P1SEL |= TXD + RXD;                        //

      P1DIR |= TXD;                              //  

    }




    // Function Transmits Character from TXByte 

    void Transmit()

      BitCnt = 0xA;                             // Load Bit counter, 8data + ST/SP

      while (CCR0 != TAR)                       // Prevent async capture

        CCR0 = TAR;                             // Current state of TA counter

      CCR0 += Bitime;                     // Some time till first bit

      TXByte |= 0x100;                        // Add mark stop bit to TXByte

      TXByte = TXByte << 1;                 // Add space start bit

      CCTL0 =  CCIS0 + OUTMOD0 + CCIE;          // TXD = mark = idle

      while ( CCTL0 & CCIE );                   // Wait for TX completion

    }




    // Timer A0 interrupt service routine

    #pragma vector=TIMERA0_VECTOR

    __interrupt void Timer_A (void)

    {

     

        CCR0 += Bitime;                           // Add Offset to CCR0  

        if (CCTL0 & CCIS0)                        // TX on CCI0B?

        {

          if ( BitCnt == 0)

            CCTL0 &= ~ CCIE;                        // All bits TXed, disable interrupt

          else

          {

            CCTL0 |=  OUTMOD2;                    // TX Space

            if (TXByte & 0x01)

            CCTL0 &= ~ OUTMOD2;                   // TX Mark

            TXByte = TXByte >> 1;

            BitCnt --;

          }

        }

      }

     

     

     

    kindly tell me why is it so?

     

     

    regards

     

     

     

     

     

     

     

     

     

     

     

     

  • If you guys are having trouble following the example code, I'd recommend starting smaller and tackle one peripheral at a time. It can be hard to break down the example code without having prior MSP430 experience. My next blog post will show how to strip the example code of everything but the software UART transmitter, so if you are curious as to how it all works, stay tuned to my blog.

    Otherwise, look into resources online and look into the data sheet for anything that seems unfamiliar. Try to become familiar with the timer at the very least before trying to understand the sample code.

    Best luck!

    -NJC

    ______________________________

    http://msp430launchpad.blogspot.com

  • hey everyone,

    I have been trying the following code to echo a character on display using TIMER A UART, but it is not working till now.

     

    Although when i was using it only for transmitting a character from MSP430 to display , it worked well but reception is not taking place . kindly have a look on the code and sugges me some changes.

    #include  "msp430x20x2.h"

    #define     TXD                   BIT1                      // TXD on P1.1

     

    #define     RXD                   BIT2                      // RXD on P1.2

    #define     Bitime_5              0x05*4                      // ~ 0.5 bit length + small adjustment

    #define     Bitime                13*4//0x0D    

     unsigned char BitCnt;

    unsigned int TXByte;

    void ConfigureTimerUart(void);  

    void Transmit(void);

    void InitializeClocks(void);

    void RX_Ready (void);

    void main(void)

    {

       WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT

      P1DIR = 0x01;

      InitializeClocks();

      __enable_interrupt();                     // Enable interrupts.

      while(1)

       {    

           ConfigureTimerUart();

           RX_Ready();                               // UART ready to RX one Byte

           Transmit();

     }}   

    void ConfigureTimerUart(void)

    {

      CCTL0 = OUT;                               // TXD Idle as Mark

      TACTL = TASSEL_2 + MC_2 + ID_3;            // SMCLK/8, continuous mode

      P1SEL |= TXD + RXD;                        //

      P1DIR |= TXD;                              //  

    }

    void Transmit()

      BitCnt = 0xA;                             // Load Bit counter, 8data + ST/SP

      while (CCR0 != TAR)                       // Prevent async capture

      CCR0 = TAR;                             // Current state of TA counter

      CCR0 += Bitime;                     // Some time till first bit

      TXByte |= 0x100;                        // Add mark stop bit to TXByte

      TXByte = TXByte << 1;                 // Add space start bit

      CCTL0 =  CCIS0 + OUTMOD0 + CCIE;          // TXD = mark = idle

      while ( CCTL0 & CCIE );                  // Wait for TX completion

    }

    void RX_Ready (void)

    {

      BitCnt = 0x8;                             // Load Bit counter

      CCTL0 = SCS + OUTMOD0 + CM1 + CAP + CCIE;   // Sync, Neg Edge, Cap

    }

    #pragma vector=TIMERA0_VECTOR

    __interrupt void Timer_A (void)

    {

        CCR0 += Bitime;                           // Add Offset to CCR0  

        if (CCTL0 & CCIS0)                        // TX on CCI0B?

        {

          if ( BitCnt == 0)

            CCTL0 &= ~ CCIE;                        // All bits TXed, disable interrupt

          else

          {

            CCTL0 |=  OUTMOD2;                    // TX Space

            if (TXByte & 0x01)

            CCTL0 &= ~ OUTMOD2;                   // TX Mark

            TXByte = TXByte >> 1;

            BitCnt --;

            P1OUT ^= 0x40;

          }

        }

        // RX

      else

      {

        if( CCTL0 & CAP )                       // Capture mode = start bit edge

        {

        CCTL0 &= ~ CAP;                         // Switch from capture to compare mode

        CCR0 += Bitime_5;

        }

        else

        {

        TXByte = TXByte >> 1;

          if (CCTL0 & SCCI)                     // Get bit waiting in receive latch

          TXByte |= 0x80;

          BitCnt --;                            // All bits RXed?

           P1OUT ^= 0x01;

    } } }}

    void InitializeClocks(void)

    {

      BCSCTL1 = CALBC1_1MHZ;                    // Set range

      DCOCTL = CALDCO_1MHZ;

      BCSCTL2 &= ~(DIVS_3);                         // SMCLK = DCO / 8 = 1MHz  

    }

     

     

    KIndly let me know what is the problem and how can i solve it?

     

    REGARDS,

    qwert

  • hey ERIC, 

     

    i did as you suggested me.... but still reception is a problem. I am not being able to receive a character from keyboard.

    I am trying to input using putty.exe, tell me what should i do ?

    here is my code...........

    #include  "msp430x20x2.h"

    #define     TXD                   BIT1                      // TXD on P1.1

     #define     RXD                   BIT2                      // RXD on P1.2

    #define     Bitime_5              0x05*4                      // ~ 0.5 bit length + small adjustment

    #define     Bitime                13*4//0x0D    

     unsigned char BitCnt;

    unsigned int TXByte;

    void ConfigureTimerUart(void);  

    void Transmit(void);

    void InitializeClocks(void);

    void RX_Ready (void);

    void main(void)

    {

       WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT

      P1DIR = 0x01;

      InitializeClocks();

      __enable_interrupt();                     // Enable interrupts.

      while(1)

       {    

           ConfigureTimerUart();

           RX_Ready();                               // UART ready to RX one Byte

           Transmit();

     }}   

    void ConfigureTimerUart(void)

    {

      CCTL0 = OUT;                               // TXD Idle as Mark

      TACTL = TASSEL_2 + MC_2 + ID_3;            // SMCLK/8, continuous mode

      P1SEL |= TXD + RXD;                        //

      P1DIR |= TXD;                              //  

    }

    void Transmit()

      BitCnt = 0xA;                             // Load Bit counter, 8data + ST/SP

      while (CCR0 != TAR)                       // Prevent async capture

      CCR0 = TAR;                             // Current state of TA counter

      CCR0 += Bitime;                     // Some time till first bit

      TXByte |= 0x100;                        // Add mark stop bit to TXByte

      TXByte = TXByte << 1;                 // Add space start bit

      CCTL0 =  CCIS0 + OUTMOD0 + CCIE;          // TXD = mark = idle

      while ( CCTL0 & CCIE );                  // Wait for TX completion

    }

    void RX_Ready (void)

    {

      BitCnt = 0x8;                             // Load Bit counter

      CCTL0 = SCS + OUTMOD0 + CM1 + CAP + CCIE;   // Sync, Neg Edge, Cap

    }

    #pragma vector=TIMERA0_VECTOR

    __interrupt void Timer_A (void)

    {

        CCR0 += Bitime;                           // Add Offset to CCR0  

        if (CCTL0 & CCIS0)                        // TX on CCI0B?

        {

          if ( BitCnt == 0)

            CCTL0 &= ~ CCIE;                        // All bits TXed, disable interrupt

          else

          {

            CCTL0 |=  OUTMOD2;                    // TX Space

            if (TXByte & 0x01)

            CCTL0 &= ~ OUTMOD2;                   // TX Mark

            TXByte = TXByte >> 1;

            BitCnt --;

            P1OUT ^= 0x40;

          }

        }

        // RX

      else

      {

        if( CCTL0 & CAP )                       // Capture mode = start bit edge

        {

        CCTL0 &= ~ CAP;                         // Switch from capture to compare mode

        CCR0 += Bitime_5;

        }

        else

        {

        TXByte = TXByte >> 1;

          if (CCTL0 & SCCI)                     // Get bit waiting in receive latch

          TXByte |= 0x80;

          BitCnt --;                            // All bits RXed?

           P1OUT ^= 0x01;

    } } }}

    void InitializeClocks(void)

    {

      BCSCTL1 = CALBC1_1MHZ;                    // Set range

      DCOCTL = CALDCO_1MHZ;

      BCSCTL2 &= ~(DIVS_3);                         // SMCLK = DCO / 8 = 1MHz  

    }

     

    hey anyone , please suggest me something . 

     

    i am not being able to trace the mistake  because everything as according to me is in proper order.

    REGARDS,

    qwert

     

**Attention** This is a public forum