Reply by Andrei Lucec February 9, 20052005-02-09
Many Thanks for the advise. I'll let you know the result.

>From: Adriano <adriano@adri...>
>Reply-To: msp430@msp4...
>To: msp430@msp4...
>Subject: Re: [msp430] Re: Please debug Timer_A UART on MSP430F1232 P1.2 RX 
>P1.3 TX
>Date: Wed, 09 Feb 2005 08:56:53 -0200
>
>
>To do that simple task, just take a look at the TACTL register in the
>user's guide. You have to configure timer in up mode and load 50000 in
>TACCR0 register. You can then enable interrupt on overflow (50000->0) by
>setting the TAIE bit on the same TACTL register. The clock source of the
>timer and the divider are also selected in this register. In the timer
>ISR, you can then turn on/off a led, and is necessary to reset the TAIFG
>flag.
>
>Regards,
>Adriano.
>
>Andrei Lucec wrote:
> > yeap, I configured the timer in compare mode.
> >
> > do you guys have a sample of the proper configuration of Timer A?
> >
> > smth simple, like select ACLK, Divided by 8, count to 50000 , turn on
a 
>LED
> > ?
> >
> > The problem is that between me and the scope there are a couple of 
>miles.
> > good luck for the
> > signal analisys ...
> >
> >
> >
> >
> > .
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >



Beginning Microcontrollers with the MSP430

Reply by Adriano February 9, 20052005-02-09
To do that simple task, just take a look at the TACTL register in the 
user's guide. You have to configure timer in up mode and load 50000 in 
TACCR0 register. You can then enable interrupt on overflow (50000->0) by 
setting the TAIE bit on the same TACTL register. The clock source of the 
timer and the divider are also selected in this register. In the timer 
ISR, you can then turn on/off a led, and is necessary to reset the TAIFG 
flag.

Regards,
Adriano.

Andrei Lucec wrote:
> yeap, I configured the timer in compare mode.
> 
> do you guys have a sample of the proper configuration of Timer A?
> 
> smth simple, like select ACLK, Divided by 8, count to 50000 , turn on a LED

> ?
> 
> The problem is that between me and the scope there are a couple of miles. 
> good luck for the
> signal analisys ...
> 
> 
> 
> 
> .
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 
> 

Reply by Andrei Lucec February 8, 20052005-02-08
yeap, I configured the timer in compare mode.

do you guys have a sample of the proper configuration of Timer A?

smth simple, like select ACLK, Divided by 8, count to 50000 , turn on a LED 
?

The problem is that between me and the scope there are a couple of miles. 
good luck for the
signal analisys ...



Reply by Adriano February 8, 20052005-02-08
Yes, Andrei, this theory is valid. But as you configure P1.2 as input, 
you can't write on it. So, I would add a pull-up resistor at this pin, 
to guarantee that it is always in a high level when the PC is not 
connected to the MSP. Have you tried to write on the P2IN register? This 
is not allowed and increase current consumption.

You also have to check if the stop bit is 1, to check the validity of 
the received byte. You're using the timer in compare mode, right? If you 
have configured timer registers correctly, it should work. But as Micah 
said, I would scope the Rx/Tx pins to check if the byte is really being 
received by the MSP.

Regards,
Adriano.


andrei_lucec wrote:
> 
>   I removed the P1SEL. Sorry for that. An older version.
> 
> Our teacher sais that we should leave P1.2 / 3 on I/O.
> 
> We should also enable interrupts on port 1.2 (RX from PC), falling 
> edge (1 to 0). Set the port on 1 (high) and if a 1 -> 0 transition 
> occurs, this will trigger the P1IFG.
> 
> When  P1IFG is set we have to start counting with the Timer
> 208 pulses (208 pulses @ 4 MHz) to "sit" on the middle of the
bit.
> 
> If the value is 0 (start bit) we can:
> 
> start a loop with 
> 
> Timer 416 pulses (416 pulses @ 4MHz  - 104 s)
> save the P1IN into a RXTXBuffer
> shift RXTXBuffer to receive all bits in the byte
> 
> Is this theory valid ?!
> 
> 
> 
> 
> 
> .
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 
> 
> 

Reply by andrei_lucec February 8, 20052005-02-08
  I removed the P1SEL. Sorry for that. An older version.

Our teacher sais that we should leave P1.2 / 3 on I/O.

We should also enable interrupts on port 1.2 (RX from PC), falling 
edge (1 to 0). Set the port on 1 (high) and if a 1 -> 0 transition 
occurs, this will trigger the P1IFG.

When  P1IFG is set we have to start counting with the Timer
208 pulses (208 pulses @ 4 MHz) to "sit" on the middle of the bit.

If the value is 0 (start bit) we can:

start a loop with 

Timer 416 pulses (416 pulses @ 4MHz  - 104 s)
save the P1IN into a RXTXBuffer
shift RXTXBuffer to receive all bits in the byte

Is this theory valid ?!




Reply by andrei_lucec February 8, 20052005-02-08
 Sorry for being unspecific. My frustration is up high ...

I received the board just like that.

It is supposed to talk to a GPS module with the embedded UART and 
with a PC with Timer A implemented one.




Reply by Adriano February 8, 20052005-02-08
Ok, Andrei, and have you thought on using an MSP with 2 UARTs, like the 
'F149, or is it not possible in your case?

Are you sure you are receiving a byte correctly? I would put a brekpoint 
in my code right after receiving it, so it's possible to compare the 
byte transferred to what was received.

I have also looked something that doesn't seem good in your code, when 
you configure port 1. You do:

P1SEL = TXD;                          // P1.1/TA0 for TXD function
P1DIR = TXD;                          // TXD output on P1
P1SEL = RXD;                          // P2.2/TA0 as RXD input

If you really want to configure P1.2 and P1.3 as peripheral function, 
you have to do something like:

P1SEL = TXD + RXD;

Otherwise, pin P1.3 will remain as I/O function, and maybe this is why 
you're not managing to transmit back the byte received.

Regards,
Adriano.


Andrei Lucec wrote:
> Yes, it has.
> 
> The problem is that we are supposed to manage 2 UARTs.
> 
> One embedded in the processor (P3.4/5 UTXD0 / URXDO)
> and
> another one developped with Timer_A
> 
> thanks
> 
> 
> 
>>From: Adriano <adriano@adri...>
>>Reply-To: msp430@msp4...
>>To: msp430@msp4...
>>Subject: Re: [msp430] Please debug  Timer_A UART on MSP430F1232 P1.2 RX 
>>P1.3 TX
>>Date: Tue, 08 Feb 2005 10:41:07 -0200
>>
>>
>>As Micah said, I think you should be more specific, Andrei, otherwise no
>>  one can help you. Hasn't the F1232 a USART module? Why don't
you use
>>it? I think it would be much simpler.
>>
>>Regards,
>>Adriano.
>>
>>andrei_lucec wrote:
>>
>>>
>>>   Hi everybody,
>>>I'm a newbee on MSP 430. Can anybody debug my code and tell me
why
>>>this ain't working?
>>>
>>>MSP 430 F1232
>>>P1.2 Rx from PC
>>>P1.3 Tx to PC
>>>LFXTCLK 4,00000 MHz
>>>
>>>
>>>#include  <msp430x12x2.h>
>>>
>>>#define RXD   0x04                      // RXD on P1.2
>>>#define TXD   0x08                      // TXD on P1.3
>>>********************************
>>>
>>>//  Conditions for 9600 Baud HW/SW UART, ACLK = 3.579545MHz
>>>
>>>#define Bitime_5  0x0BA                 // ~ 0.5 bit length
>>>#define Bitime  0x175                   // 104 us ~ 9596 baud
>>>
>>>unsigned int RXTXData;
>>>unsigned char BitCnt;
>>>
>>>void TX_Byte (void);
>>>void RX_Ready (void);
>>>
>>>void main(void)
>>>{
>>>  unsigned int i;
>>>  WDTCTL = WDTPW + WDTHOLD;             // Stop watchdog timer
>>>
>>>  BCSCTL1 |= XTS;                       // ACLK = LFXT1 = HF XTAL
>>>
>>>  do
>>>  {
>>>    IFG1 &= ~OFIFG;                     // Clear OSCFault flag
>>>    for (i = 0xFF; i > 0; i--);         // Time for flag to set
>>>  }
>>>  while (IFG1 & OFIFG);                 // OSCFault flag still
>>>set?
>>>
>>>  BCSCTL2 |= SELM1+SELM0;               // MCLK = LFXT1 (safe)
>>>
>>>  CCTL0 = OUT;                          // TXD Idle as Mark
>>>  TACTL = TASSEL_1+MC_1;                  // ACLK, continous
mode
>>>*******************
>>>  P1SEL = TXD;                          // P1.1/TA0 for TXD function
>>>  P1DIR = TXD;                          // TXD output on P1
>>>  P1SEL = RXD;                          // P2.2/TA0 as RXD input
>>>********************
>>>
>>>// Mainloop
>>>  for (;;)
>>>  {
>>>    RX_Ready();                         // UART ready to RX one Byte
>>>    _BIS_SR(CPUOFF+GIE);                // Enter LPM0 Until
>>>character 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
>>>  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 = 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+CCIS0+OUTMOD0+CM1+CAP+CCIE;   //
Sync, Neg Edge,
>>>Capture
>>>}
>>>
>>>// Timer A0 interrupt service routine
>>>interrupt [TIMERA0_VECTOR] void Timer_A
>>>(void)  //************************
>>>{
>>>  CCR0 += Bitime;                       // Add Offset to CCR0
>>>
>>>// RX
>>>  if (CCTL0 & CCIS0)                    // RX on CCI0B?
>>>  {
>>>    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(CPUOFF);              // Clear LPM0 bits from
0(SR)
>>>      }
>>>//>>>>>>>>>> Decode of Received Byte
Here
>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>>>    }
>>>  }
>>>// TX
>>>  else
>>>  {
>>>    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 --;
>>>    }
>>>  }
>>>}
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>.
>>>
>>>
>>>Yahoo! Groups Links
>>>
>>>
>>>
>>>
>>>
>>>
>>>
> 
> 
> 
> 
> 
> .
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 
> 

Reply by Micah Stevens February 8, 20052005-02-08
Haha.. I'm trying to make a point and you just ruin it for me. 

:) 

On Tuesday 08 February 2005 08:34 am, Robert Bacs
wrote:
> Hi,
>
> If you writed this code after the assembler example
> after the SLAA078A Application report you forget to
> enable interrupts after the do-while loop.
>
> Regards,
> Boby
>
> --- andrei_lucec <andreilucec@andr...> wrote:
> > It's not working means that it' s not resending the
> > received data.
> >
> > RX >> TX
> >
> > thanks
> >
> > --- In msp430@msp4..., Micah Stevens
> >
> > <micah@9...> wrote:
> > > What isn't working?
> > > What isn't it doing?
> > > Is it compiling?
> > > Is it receiving?
> > > Is it transmitting?
> > > Is it not doing anything?
> > > What is it supposed to do?
> > >
> > >
> > >
> > >
> > >
> > >
> > > On Monday 07 February 2005 02:13 pm, andrei_lucec
> >
> > wrote:
> > > >   Hi everybody,
> > > >  I'm a newbee on MSP 430. Can anybody debug my
> >
> > code and tell me
> > why
> >
> > > >  this ain't working?
> > > >
> > > >  MSP 430 F1232
> > > >  P1.2 Rx from PC
> > > >  P1.3 Tx to PC
> > > >  LFXTCLK 4,00000 MHz
> > > >
> > > >
> > > >  #include <msp430x12x2.h>
> > > >
> > > >  #define RXD 0x04 // RXD
> >
> > on P1.2
> >
> > > >  #define TXD 0x08 // TXD
> >
> > on P1.3
> >
> > > >  ********************************
> > > >
> > > >  // Conditions for 9600 Baud HW/SW UART, ACLK > >
> > 3.579545MHz
> >
> > > >  #define Bitime_5 0x0BA // ~
> >
> > 0.5 bit length
> >
> > > >  #define Bitime 0x175 // 104
> >
> > us ~ 9596 baud
> >
> > > >  unsigned int RXTXData;
> > > >  unsigned char BitCnt;
> > > >
> > > >  void TX_Byte (void);
> > > >  void RX_Ready (void);
> > > >
> > > >  void main(void)
> > > >  {
> > > >   unsigned int i;
> > > >   WDTCTL = WDTPW + WDTHOLD; // Stop
> >
> > watchdog timer
> >
> > > >   BCSCTL1 |= XTS; // ACLK
> >
> > = LFXT1 = HF
> > XTAL
> >
> > > >   do
> > > >   {
> > > >   IFG1 &= ~OFIFG; //
> >
> > Clear OSCFault flag
> >
> > > >   for (i = 0xFF; i > 0; i--); // Time
> >
> > for flag to set
> >
> > > >   }
> > > >   while (IFG1 & OFIFG); //
> >
> > OSCFault flag still
> >
> > > >  set?
> > > >
> > > >   BCSCTL2 |= SELM1+SELM0; // MCLK
> >
> > = LFXT1 (safe)
> >
> > > >   CCTL0 = OUT; // TXD
> >
> > Idle as Mark
> >
> > > >   TACTL = TASSEL_1+MC_1; //
> >
> > ACLK, continous
> > mode
> >
> > > >  *******************
> > > >   P1SEL = TXD; //
> >
> > P1.1/TA0 for TXD
> > function
> >
> > > >   P1DIR = TXD; // TXD
> >
> > output on P1
> >
> > > >   P1SEL = RXD; //
> >
> > P2.2/TA0 as RXD input
> >
> > > >  ********************
> > > >
> > > >  // Mainloop
> > > >   for (;;)
> > > >   {
> > > >   RX_Ready(); // UART
> >
> > ready to RX one
> > Byte
> >
> > > >   _BIS_SR(CPUOFF+GIE); //
> >
> > Enter LPM0 Until
> >
> > > >  character 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
> > > >   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 = 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+CCIS0+OUTMOD0+CM1+CAP+CCIE; //
> >
> > Sync, Neg Edge,
> >
> > > >  Capture
> > > >  }
> > > >
> > > >  // Timer A0 interrupt service routine
> > > >  interrupt [TIMERA0_VECTOR] void Timer_A
> > > >  (void) //************************
> > > >  {
> > > >   CCR0 += Bitime; // Add
> >
> > Offset to CCR0
> >
> > > >  // RX
> > > >   if (CCTL0 & CCIS0) // RX
> >
> > on CCI0B?
> >
> > > >   {
> > > >   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(CPUOFF); //
> >
> > Clear LPM0 bits from
> > 0(SR)
> >
> > > >   }
> > > >  //>>>>>>>>>> Decode of
Received Byte Here
> > > > 
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> > > >   }
> > > >   }
> > > >  // TX
>
> === message truncated ==>
>
>
>
> __________________________________
> 
>
>
> .
>
>
> Yahoo! Groups Links
>
>
>
Reply by Robert Bacs February 8, 20052005-02-08
Hi,

If you writed this code after the assembler example 
after the SLAA078A Application report you forget to
enable interrupts after the do-while loop.

Regards,
Boby

--- andrei_lucec <andreilucec@andr...> wrote:

> 
> It's not working means that it' s not resending the
> received data.
> 
> RX >> TX
> 
> thanks 
> 
> --- In msp430@msp4..., Micah Stevens
> <micah@9...> wrote:
> > 
> > What isn't working? 
> > What isn't it doing?
> > Is it compiling? 
> > Is it receiving?
> > Is it transmitting?
> > Is it not doing anything?
> > What is it supposed to do?
> > 
> > 
> > 
> > 
> > 
> > 
> > On Monday 07 February 2005 02:13 pm, andrei_lucec
> wrote:
> > >   Hi everybody,
> > >  I'm a newbee on MSP 430. Can anybody debug my
> code and tell me 
> why
> > >  this ain't working?
> > >
> > >  MSP 430 F1232
> > >  P1.2 Rx from PC
> > >  P1.3 Tx to PC
> > >  LFXTCLK 4,00000 MHz
> > >
> > >
> > >  #include <msp430x12x2.h>
> > >
> > >  #define RXD 0x04 // RXD
> on P1.2
> > >  #define TXD 0x08 // TXD
> on P1.3
> > >  ********************************
> > >
> > >  // Conditions for 9600 Baud HW/SW UART, ACLK > 3.579545MHz
> > >
> > >  #define Bitime_5 0x0BA // ~
> 0.5 bit length
> > >  #define Bitime 0x175 // 104
> us ~ 9596 baud
> > >
> > >  unsigned int RXTXData;
> > >  unsigned char BitCnt;
> > >
> > >  void TX_Byte (void);
> > >  void RX_Ready (void);
> > >
> > >  void main(void)
> > >  {
> > >   unsigned int i;
> > >   WDTCTL = WDTPW + WDTHOLD; // Stop
> watchdog timer
> > >
> > >   BCSCTL1 |= XTS; // ACLK
> = LFXT1 = HF 
> XTAL
> > >
> > >   do
> > >   {
> > >   IFG1 &= ~OFIFG; //
> Clear OSCFault flag
> > >   for (i = 0xFF; i > 0; i--); // Time
> for flag to set
> > >   }
> > >   while (IFG1 & OFIFG); //
> OSCFault flag still
> > >  set?
> > >
> > >   BCSCTL2 |= SELM1+SELM0; // MCLK
> = LFXT1 (safe)
> > >
> > >   CCTL0 = OUT; // TXD
> Idle as Mark
> > >   TACTL = TASSEL_1+MC_1; //
> ACLK, continous 
> mode
> > >  *******************
> > >   P1SEL = TXD; //
> P1.1/TA0 for TXD 
> function
> > >   P1DIR = TXD; // TXD
> output on P1
> > >   P1SEL = RXD; //
> P2.2/TA0 as RXD input
> > >  ********************
> > >
> > >  // Mainloop
> > >   for (;;)
> > >   {
> > >   RX_Ready(); // UART
> ready to RX one 
> Byte
> > >   _BIS_SR(CPUOFF+GIE); //
> Enter LPM0 Until
> > >  character 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
> > >   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 = 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+CCIS0+OUTMOD0+CM1+CAP+CCIE;
//
> Sync, Neg Edge,
> > >  Capture
> > >  }
> > >
> > >  // Timer A0 interrupt service routine
> > >  interrupt [TIMERA0_VECTOR] void Timer_A
> > >  (void) //************************
> > >  {
> > >   CCR0 += Bitime; // Add
> Offset to CCR0
> > >
> > >  // RX
> > >   if (CCTL0 & CCIS0) // RX
> on CCI0B?
> > >   {
> > >   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(CPUOFF); //
> Clear LPM0 bits from 
> 0(SR)
> > >   }
> > >  //>>>>>>>>>> Decode of Received
Byte Here
> > > 
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> > >   }
> > >   }
> > >  // TX
> 
=== message truncated ==


		
__________________________________ 


Reply by Micah Stevens February 8, 20052005-02-08
Where is the data stopping? I have had great success in using printf() 
statements in debug mode to echo data out the jtag to help me figure out 
where something is failing. 

You didn't answer hardly any of my questions, which were more meant to help

than just be rude. Sorry if it seemed that way. But you haven't even given
us 
enough information to know if we should be looking for syntax errors, or 
what. I assume by the way you talk about it it at least compiles, but you 
never stated this so I could be wrong. 

I've never seen compiled software that doesn't do anything. It's
at least 
doing something, troubleshooting involves figuring what it IS doing, and why 
it's not doing everything you want it to. 

Does is Receive data properly? If so, then it's half way there. If not, you

need to look in the receive side. Did you hook a scope up to the uart to see 
if the signal is getting at least that far? how about on the TX side, is is 
failing somewhere in the signal path outside the chip?

Once you narrow it down to something that is specific, I'm sure
there's plenty 
of people on this list that would love to help you out with it. Just my two 
cents.. :) 


-Micah 

On Tuesday 08 February 2005 07:55 am, andrei_lucec
wrote:
>  It's not working means that it' s not resending the received
data.
>
>  RX >> TX
>
>  thanks
>
>  --- In msp430@msp4..., Micah Stevens <micah@9...> wrote:
>  > What isn't working?
>  > What isn't it doing?
>  > Is it compiling?
>  > Is it receiving?
>  > Is it transmitting?
>  > Is it not doing anything?
>  > What is it supposed to do?
>  >
>  > On Monday 07 February 2005 02:13 pm, andrei_lucec wrote:
>  > >  Hi everybody,
>  > > I'm a newbee on MSP 430. Can anybody debug my code and
tell me
>
>  why
>
>  > > this ain't working?
>  > >
>  > > MSP 430 F1232
>  > > P1.2 Rx from PC
>  > > P1.3 Tx to PC
>  > > LFXTCLK 4,00000 MHz
>  > >
>  > >
>  > > #include <msp430x12x2.h>
>  > >
>  > > #define RXD 0x04 // RXD on P1.2
>  > > #define TXD 0x08 // TXD on P1.3
>  > > ********************************
>  > >
>  > > // Conditions for 9600 Baud HW/SW UART, ACLK = 3.579545MHz
>  > >
>  > > #define Bitime_5 0x0BA // ~ 0.5 bit length
>  > > #define Bitime 0x175 // 104 us ~ 9596 baud
>  > >
>  > > unsigned int RXTXData;
>  > > unsigned char BitCnt;
>  > >
>  > > void TX_Byte (void);
>  > > void RX_Ready (void);
>  > >
>  > > void main(void)
>  > > {
>  > >  unsigned int i;
>  > >  WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
>  > >
>  > >  BCSCTL1 |= XTS; // ACLK = LFXT1 = HF
>
>  XTAL
>
>  > >  do
>  > >  {
>  > >  IFG1 &= ~OFIFG; // Clear OSCFault
flag
>  > >  for (i = 0xFF; i > 0; i--); // Time for flag to
set
>  > >  }
>  > >  while (IFG1 & OFIFG); // OSCFault flag
still
>  > > set?
>  > >
>  > >  BCSCTL2 |= SELM1+SELM0; // MCLK = LFXT1
(safe)
>  > >
>  > >  CCTL0 = OUT; // TXD Idle as Mark
>  > >  TACTL = TASSEL_1+MC_1; // ACLK,
continous
>
>  mode
>
>  > > *******************
>  > >  P1SEL = TXD; // P1.1/TA0 for TXD
>
>  function
>
>  > >  P1DIR = TXD; // TXD output on P1
>  > >  P1SEL = RXD; // P2.2/TA0 as RXD
input
>  > > ********************
>  > >
>  > > // Mainloop
>  > >  for (;;)
>  > >  {
>  > >  RX_Ready(); // UART ready to RX one
>
>  Byte
>
>  > >  _BIS_SR(CPUOFF+GIE); // Enter LPM0 Until
>  > > character 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
>  > >  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 = 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+CCIS0+OUTMOD0+CM1+CAP+CCIE;
// Sync, Neg Edge,
>  > > Capture
>  > > }
>  > >
>  > > // Timer A0 interrupt service routine
>  > > interrupt [TIMERA0_VECTOR] void Timer_A
>  > > (void) //************************
>  > > {
>  > >  CCR0 += Bitime; // Add Offset to CCR0
>  > >
>  > > // RX
>  > >  if (CCTL0 & CCIS0) // RX on CCI0B?
>  > >  {
>  > >  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(CPUOFF); // Clear LPM0 bits from
>
>  0(SR)
>
>  > >  }
>  > > //>>>>>>>>>> Decode of Received
Byte Here
>  > >
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>  > >  }
>  > >  }
>  > > // TX
>  > >  else
>  > >  {
>  > >  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 --;
>  > >  }
>  > >  }
>  > > }
>  > >
>  > >
>  > >
>  > >
>  > >
>  > >
>  > >
>  > >
>  > > .
>  > >
>  > >
>  > >
>  > >
>  > >
>  > >
>  > > 
>  > >
>  > >
>  > >
>  > >
>  > >
>  > >
>  > > .