Sign in

username:

password:



Not a member?

Search msp430



Search tips

Subscribe to msp430



Ads

Discussion Groups

See Also

DSPFPGAElectronics

Discussion Groups | MSP430 | Software Uart, strange problem.

The purpose of this group is to foster exchange of information on the Texas Instruments MSP430 family of microcontrollers and related tools. Everyone welcome, all levels of familiarity/expertise.

Software Uart, strange problem. - bob_shaftenkluger - Sep 15 19:23:11 2009

I've been playing around with a loopback test with f2012, using the ti example code, and get errors roughly every ten letters sent. If I tell IAR to stop debugging, the errors go away.
This is a minor problem so far, but could be a pain in the future. Can anybody give me a solution to this? Or an explanation as to why it happens?

------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )


Re: Software Uart, strange problem. - tintronic - Sep 16 14:22:31 2009

Without at least knowing the code and the error, little can we help.
If you want help, make it easy for people to help you.

Regards,
Michael K.

--- In m...@yahoogroups.com, "bob_shaftenkluger" wrote:
>
> I've been playing around with a loopback test with f2012, using the ti example code, and get errors roughly every ten letters sent. If I tell IAR to stop debugging, the errors go away.
> This is a minor problem so far, but could be a pain in the future. Can anybody give me a solution to this? Or an explanation as to why it happens?
>
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: Software Uart, strange problem. - old_cow_yellow - Sep 16 15:02:57 2009

I read the manual. I checked the hardware. I did everything correctly, but it does not work. What is wrong?

--- In m...@yahoogroups.com, "tintronic" wrote:
>
> Without at least knowing the code and the error, little can we help.
> If you want help, make it easy for people to help you.
>
> Regards,
> Michael K.
>
> --- In m...@yahoogroups.com, "bob_shaftenkluger" wrote:
> >
> > I've been playing around with a loopback test with f2012, using the ti example code, and get errors roughly every ten letters sent. If I tell IAR to stop debugging, the errors go away.
> > This is a minor problem so far, but could be a pain in the future. Can anybody give me a solution to this? Or an explanation as to why it happens?
>

------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: Re: Software Uart, strange problem. - Augusto Einsfeldt - Sep 16 15:53:55 2009


The OP is asking why while he kept the IAR's debug window open the
error happens and without it the software runs normally.
I guess there is a problem with in-system emulation hardware for
this device (debug port). I would suggest to look on errata report
for the device.
-Augusto
On Qua 16/09/09 16:01 , "old_cow_yellow" o...@yahoo.com
sent:
I read the manual. I checked the hardware. I did everything
correctly, but it does not work. What is wrong?
--- In m...@yahoogroups.com, "tintronic" wrote:
>
> Without at least knowing the code and the error, little can we
help.
> If you want help, make it easy for people to help you.
>
> Regards,
> Michael K.
>
> --- In m...@yahoogroups.com, "bob_shaftenkluger" wrote:
> >
> > I've been playing around with a loopback test with f2012, using
the ti example code, and get errors roughly every ten letters sent.
If I tell IAR to stop debugging, the errors go away.
> > This is a minor problem so far, but could be a pain in the
future. Can anybody give me a solution to this? Or an explanation as
to why it happens?
> >
>

[Non-text portions of this message have been removed]

------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: Software Uart, strange problem. - bob_shaftenkluger - Sep 16 16:09:00 2009

The code is from the ti website. I will post it here, but I guessed people=
would already have it. Seems I was wrong. The problem is that the loopback=
test sometimes gives back the wrong letters.=20
For example, if I hold down "p", by the time it has looped through my circu=
it it looks like "pp=B8p=B8p=B8p=B8pppppppppp=B8p=B8p=B8p=B8p=B8pppppppppp=
=B8p=B8p=B8p=B8", except the "=B8" looks like a little circle with somethin=
g inside it.
The cause of this I don't know, that's what I was asking about.
I didn't read the manual, because I have no idea which bit I should be read=
ing.
I checked the hardware, this could be the problem, as the circuit is just l=
aid out rather chaotically on a breadboard. As I said, the problem is only =
there when the debugger is running, so I tried moving the wires for the deb=
ugger away from the others, with no effect.
Maybe the time the msp430 was talking to the debugger messed up the timing=
of the uart somehow.

Here is the code...

//*************************************************************************=
*****
// MSP430F20xx Demo - Timer_A, Ultra-Low Pwr UART 2400 Echo, 32kHz ACLK
//
// Description: Use Timer_A CCR0 hardware output modes and SCCI data latch
// to implement UART function @ 2400 baud. Software does not directly read=
and
// write to RX and TX pins, instead proper use of output modes and SCCI da=
ta
// latch are demonstrated. Use of these hardware features eliminates ISR
// latency effects as hardware insures that output and input bit latching =
and
// timing are perfectly synchronised with Timer_A regardless of other
// software activity. In the Mainloop the UART function readies the UART t=
o
// receive one character and waits in LPM3 with all activity interrupt dri=
ven.
// After a character has been received, the UART receive function forces e=
xit
// from LPM3 in the Mainloop which echo's back the received character.
// ACLK =3D TACLK =3D LFXT1 =3D 32768Hz, MCLK =3D SMCLK =3D default DCO
// //* An external watch crystal is required on XIN XOUT for ACLK *//=09
//
// MSP430F20xx
// -----------------
// /|\| XIN|-
// | | | 32kHz
// --|RST XOUT|-
// | |
// | CCI0B/TXD/P1.5|-------->
// | | 2400 8N1
// | CCI0A/RXD/P1.1|<--------
//
#define RXD 0x02 // RXD on P1.1
#define TXD 0x20 // TXD on P1.5

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

#define Bitime_5 0x06 // ~ 0.5 bit length + small adj=
ustment
#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
void main (void)
{
WDTCTL =3D WDTPW + WDTHOLD; // Stop watchdog timer
CCTL0 =3D OUT; // TXD Idle as Mark
TACTL =3D TASSEL_1 + MC_2; // ACLK, continuous mode
P1SEL =3D TXD + RXD; //
P1DIR =3D TXD; //

// Mainloop
for (;;)
{
RX_Ready(); // UART ready to RX one Byte
_BIS_SR(LPM3_bits + GIE); // Enter LPM3 w/ interr until c=
har RXed
TX_Byte(); // TX Back RXed Byte Received
}
}
// Function Transmits Character from RXTXData Buffer
void TX_Byte (void)
{
BitCnt =3D 0xA; // Load Bit counter, 8data + =
ST/SP
while (CCR0 !=3D TAR) // Prevent async capture
CCR0 =3D TAR; // Current state of TA counte=
r
CCR0 +=3D Bitime; // Some time till first bit
RXTXData |=3D 0x100; // Add mark stop bit to RXTXD=
ata
RXTXData =3D RXTXData << 1; // Add space start bit
CCTL0 =3D CCIS0 + OUTMOD0 + CCIE; // TXD =3D mark =3D idle
while ( CCTL0 & CCIE ); // Wait for TX completion
}
// Function Readies UART to Receive Character into RXTXData Buffer
void RX_Ready (void)
{
BitCnt =3D 0x8; // Load Bit counter
CCTL0 =3D SCS + OUTMOD0 + CM1 + CAP + CCIE; // Sync, Neg Edge, Cap
}

// Timer A0 interrupt service routine
#pragma vector=3DTIMERA0_VECTOR
__interrupt void Timer_A (void)
{
CCR0 +=3D Bitime; // Add Offset to CCR0

// TX
if (CCTL0 & CCIS0) // TX on CCI0B?
{
if ( BitCnt =3D=3D 0)
CCTL0 &=3D ~ CCIE; // All bits TXed, disable int=
errupt
else
{
CCTL0 |=3D OUTMOD2; // TX Space
if (RXTXData & 0x01)
CCTL0 &=3D ~ OUTMOD2; // TX Mark
RXTXData =3D RXTXData >> 1;
BitCnt --;
}
}
// RX
else
{
if( CCTL0 & CAP ) // Capture mode =3D start bit e=
dge
{
CCTL0 &=3D ~ CAP; // Switch from capture to com=
pare mode
CCR0 +=3D Bitime_5;
}
else
{
RXTXData =3D RXTXData >> 1;
if (CCTL0 & SCCI) // Get bit waiting in receive l=
atch
RXTXData |=3D 0x80;
BitCnt --; // All bits RXed?
if ( BitCnt =3D=3D 0)
//>>>>>>>>>> Decode of Received Byte Here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<=
<<<<<
{
CCTL0 &=3D ~ CCIE; // All bits RXed, disable int=
errupt
_BIC_SR_IRQ(LPM3_bits); // Clear LPM3 bits from 0(SR)
}
//>>>>>>>>>> Decode of Received Byte Here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<=
<<<<<
}
}
}
------------------------------------

______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.


(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: Software Uart, strange problem. - bob_shaftenkluger - Sep 16 16:11:28 2009

Hi Augusto,
You replied while I was typing. I will go have a look at that.

--- In m...@yahoogroups.com, Augusto Einsfeldt wrote:
>
>
> The OP is asking why while he kept the IAR's debug window open the
> error happens and without it the software runs normally.
> I guess there is a problem with in-system emulation hardware for
> this device (debug port). I would suggest to look on errata report
> for the device.
> -Augusto
> On Qua 16/09/09 16:01 , "old_cow_yellow" old_cow_yellow@...
> sent:
> I read the manual. I checked the hardware. I did everything
> correctly, but it does not work. What is wrong?
> --- In m...@yahoogroups.com, "tintronic" wrote:
> >
> > Without at least knowing the code and the error, little can we
> help.
> > If you want help, make it easy for people to help you.
> >
> > Regards,
> > Michael K.
> >
> > --- In m...@yahoogroups.com, "bob_shaftenkluger" wrote:
> > >
> > > I've been playing around with a loopback test with f2012, using
> the ti example code, and get errors roughly every ten letters sent.
> If I tell IAR to stop debugging, the errors go away.
> > > This is a minor problem so far, but could be a pain in the
> future. Can anybody give me a solution to this? Or an explanation as
> to why it happens?
> > >
> >
>
> [Non-text portions of this message have been removed]
>
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: Software Uart, strange problem. - Michael - Sep 16 16:35:12 2009

> > The OP is asking why while he kept the IAR's debug window open
> > the error happens and without it the software runs normally.
In that case it could be as simple as having the debugger configured in singlestep mode, maybe messing up the reception rather than the loopback transmission.

> I didn't read the manual, because I have no idea which bit I should
> be reading.
You're kidding, right?! It's like saying "I don't know how to turn my Notebook on, and I haven't read the manual because I don't know for which button to look for". You can't know unless you read the manual!

Michael K.

--- In m...@yahoogroups.com, "bob_shaftenkluger" wrote:
>
> Hi Augusto,
> You replied while I was typing. I will go have a look at that.
>
> --- In m...@yahoogroups.com, Augusto Einsfeldt wrote:
> >
> >
> > The OP is asking why while he kept the IAR's debug window open the
> > error happens and without it the software runs normally.
> > I guess there is a problem with in-system emulation hardware for
> > this device (debug port). I would suggest to look on errata report
> > for the device.
> > -Augusto
> > On Qua 16/09/09 16:01 , "old_cow_yellow" old_cow_yellow@
> > sent:
> > I read the manual. I checked the hardware. I did everything
> > correctly, but it does not work. What is wrong?
> > --- In m...@yahoogroups.com, "tintronic" wrote:
> > >
> > > Without at least knowing the code and the error, little can we
> > help.
> > > If you want help, make it easy for people to help you.
> > >
> > > Regards,
> > > Michael K.
> > >
> > > --- In m...@yahoogroups.com, "bob_shaftenkluger" wrote:
> > > >
> > > > I've been playing around with a loopback test with f2012, using
> > the ti example code, and get errors roughly every ten letters sent.
> > If I tell IAR to stop debugging, the errors go away.
> > > > This is a minor problem so far, but could be a pain in the
> > future. Can anybody give me a solution to this? Or an explanation as
> > to why it happens?
> > > >
> > >
> >
> >
> >
> > [Non-text portions of this message have been removed]
>

------------------------------------

______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.


(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: Software Uart, strange problem. - old_cow_yellow - Sep 16 22:45:29 2009

Are you using the same PC to run the IAR-Debugger to also run a terminal em=
ulator which you keep sending "p" and viewing what are echoed back?

I have a silly thought. Maybe it is the PC that cannot chew gum and walk at=
the same time.

Another unrelated idea is to try the following. Insert the line:
if (RXTXData <> 0x70) RXTXData =3D 0x71;
inside the TX_Byte() routing between the two existing lines:
CCR0 +=3D Bitime;
RXTXData |=3D 0x100;
This way, when you keep sending "p" it should still echo "p". But if it was=
received incorrectly, it will echo "q" instead.

--- In m...@yahoogroups.com, "bob_shaftenkluger" =
wrote:
>
> The code is from the ti website. I will post it here, but I guessed peop=
le would already have it. Seems I was wrong. The problem is that the loopba=
ck test sometimes gives back the wrong letters.=20
> For example, if I hold down "p", by the time it has looped through my cir=
cuit it looks like "pp=B8p=B8p=B8p=B8pppppppppp=B8p=B8p=B8p=B8p=B8ppppppppp=
p=B8p=B8p=B8p=B8", except the "=B8" looks like a little circle with somethi=
ng inside it.
> The cause of this I don't know, that's what I was asking about.
> I didn't read the manual, because I have no idea which bit I should be re=
ading.
> I checked the hardware, this could be the problem, as the circuit is just=
laid out rather chaotically on a breadboard. As I said, the problem is onl=
y there when the debugger is running, so I tried moving the wires for the d=
ebugger away from the others, with no effect.
> Maybe the time the msp430 was talking to the debugger messed up the timi=
ng of the uart somehow.
>=20
> Here is the code...
>=20
> //***********************************************************************=
*******
> // MSP430F20xx Demo - Timer_A, Ultra-Low Pwr UART 2400 Echo, 32kHz ACLK
> //
> // Description: Use Timer_A CCR0 hardware output modes and SCCI data lat=
ch
> // to implement UART function @ 2400 baud. Software does not directly re=
ad and
> // write to RX and TX pins, instead proper use of output modes and SCCI =
data
> // latch are demonstrated. Use of these hardware features eliminates ISR
> // latency effects as hardware insures that output and input bit latchin=
g and
> // timing are perfectly synchronised with Timer_A regardless of other
> // software activity. In the Mainloop the UART function readies the UART=
to
> // receive one character and waits in LPM3 with all activity interrupt d=
riven.
> // After a character has been received, the UART receive function forces=
exit
> // from LPM3 in the Mainloop which echo's back the received character.
> // ACLK =3D TACLK =3D LFXT1 =3D 32768Hz, MCLK =3D SMCLK =3D default DCO
> // //* An external watch crystal is required on XIN XOUT for ACLK *//=09
> //
> // MSP430F20xx
> // -----------------
> // /|\| XIN|-
> // | | | 32kHz
> // --|RST XOUT|-
> // | |
> // | CCI0B/TXD/P1.5|-------->
> // | | 2400 8N1
> // | CCI0A/RXD/P1.1|<--------
> //
> #define RXD 0x02 // RXD on P1.1
> #define TXD 0x20 // TXD on P1.5
>=20
> // Conditions for 2400 Baud SW UART, ACLK =3D 32768
>=20
> #define Bitime_5 0x06 // ~ 0.5 bit length + small a=
djustment
> #define Bitime 0x0E // 427us bit length ~ 2341 ba=
ud
>=20
> unsigned int RXTXData;
> unsigned char BitCnt;
>=20
> void TX_Byte (void);
> void RX_Ready (void);
>=20
> // M. Buccini / L. Westlund
> // Texas Instruments Inc.
> // October 2005
> // Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.4=
0A
> //***********************************************************************=
*******
>=20
> #include
>=20
>=20
> void main (void)
> {
> WDTCTL =3D WDTPW + WDTHOLD; // Stop watchdog timer
> CCTL0 =3D OUT; // TXD Idle as Mark
> TACTL =3D TASSEL_1 + MC_2; // ACLK, continuous mode
> P1SEL =3D TXD + RXD; //
> P1DIR =3D TXD; //
>=20
> // 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
> }
> }
>=20
>=20
> // Function Transmits Character from RXTXData Buffer
> void TX_Byte (void)
> {
> BitCnt =3D 0xA; // Load Bit counter, 8data =
+ ST/SP
> while (CCR0 !=3D TAR) // Prevent async capture
> CCR0 =3D TAR; // Current state of TA coun=
ter
> CCR0 +=3D Bitime; // Some time till first bit
> RXTXData |=3D 0x100; // Add mark stop bit to RXT=
XData
> RXTXData =3D RXTXData << 1; // Add space start bit
> CCTL0 =3D CCIS0 + OUTMOD0 + CCIE; // TXD =3D mark =3D idle
> while ( CCTL0 & CCIE ); // Wait for TX completion
> }
>=20
>=20
> // Function Readies UART to Receive Character into RXTXData Buffer
> void RX_Ready (void)
> {
> BitCnt =3D 0x8; // Load Bit counter
> CCTL0 =3D SCS + OUTMOD0 + CM1 + CAP + CCIE; // Sync, Neg Edge, Cap
> }
>=20
> // Timer A0 interrupt service routine
> #pragma vector=3DTIMERA0_VECTOR
> __interrupt void Timer_A (void)
> {
> CCR0 +=3D Bitime; // Add Offset to CCR0
>=20
> // TX
> if (CCTL0 & CCIS0) // TX on CCI0B?
> {
> if ( BitCnt =3D=3D 0)
> CCTL0 &=3D ~ CCIE; // All bits TXed, disable i=
nterrupt
> else
> {
> CCTL0 |=3D OUTMOD2; // TX Space
> if (RXTXData & 0x01)
> CCTL0 &=3D ~ OUTMOD2; // TX Mark
> RXTXData =3D RXTXData >> 1;
> BitCnt --;
> }
> }
> // RX
> else
> {
> if( CCTL0 & CAP ) // Capture mode =3D start bit=
edge
> {
> CCTL0 &=3D ~ CAP; // Switch from capture to c=
ompare mode
> CCR0 +=3D Bitime_5;
> }
> else
> {
> RXTXData =3D RXTXData >> 1;
> if (CCTL0 & SCCI) // Get bit waiting in receive=
latch
> RXTXData |=3D 0x80;
> BitCnt --; // All bits RXed?
> if ( BitCnt =3D=3D 0)
> //>>>>>>>>>> Decode of Received Byte Here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<=
<<<<<<<
> {
> CCTL0 &=3D ~ CCIE; // All bits RXed, disable i=
nterrupt
> _BIC_SR_IRQ(LPM3_bits); // Clear LPM3 bits from 0(SR)
> }
> //>>>>>>>>>> Decode of Received Byte Here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<=
<<<<<<<
> }
> }
> }
>
------------------------------------

______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.


(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Casting value - =?iso-8859-1?Q?FabWar=AE?= - Sep 17 1:14:22 2009

Hello all,

I got two integer value eg: mv=0xFA12 and mv1=0xBACC. I want to combine this two number to store in 32 bit address.
I try like this
#define Store ((long *)0x109C)
Store[count+3]=(long)(((long)mv1 << 16) |mv);

but the result bcome Store=12FAFFFF
How do I fix this problem?
thanks

[Non-text portions of this message have been removed]

------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: Casting value - jedi_erdi - Sep 17 5:16:09 2009

FabWar wrote:
"I got two integer value eg: mv=3D0xFA12 and mv1=3D0xBACC. I want to co=
mbine this two number to store in 32 bit address.
> I try like this
> #define Store ((long *)0x109C)=20=20=20=20
> Store[count+3]=3D(long)(((long)mv1 << 16) |mv);=20
>=20
> but the result bcome Store=3D12FAFFFF=20=20=20
> How do I fix this problem?
> thanks"
You can use memcpy() function for that. First you may generate a 4 bytes ar=
ray and store the 16 bit numbers into it using memcpy(), after that, u may =
use memcpy() function to store the combined numbers into 4 bytes long. En e=
xample below:
// after all the real number will be stored in new_num which is 4 //bytes
unsigned int num1, num2;
unsigned char temp[4];
unsigned long new_num;
//
memcpy(&temp[0], num1, 2);
memcpy(&temp[2], num2, 2);
memcpy(&new_num, &temp[0], 4);

--- In m...@yahoogroups.com, FabWar=AE wrote:
>
> Hello all,
>=20
> I got two integer value eg: mv=3D0xFA12 and mv1=3D0xBACC. I want to c=
ombine this two number to store in 32 bit address.
> I try like this
> #define Store ((long *)0x109C)=20=20=20=20
> Store[count+3]=3D(long)(((long)mv1 << 16) |mv);=20
>=20
> but the result bcome Store=3D12FAFFFF=20=20=20
> How do I fix this problem?
> thanks
>=20
>=20
>=20
>=20=20=20=20=20=20=20
>=20
> [Non-text portions of this message have been removed]
>
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )