SparkFun Forums 

Where electronics enthusiasts find answers.

Discussions on how to get your MSP JTAG programmer up and running.
User avatar
By leon_heller
#73062
You have to write another one.

Leon
By naz
#73065
leon give me some idea i'll do it and finish it.
By Roko
#73083
Naz;

I suggest you read through the MSP430 User guide, specifically the see the section on the Timer_A module. Go through your current software UART code, and make sure you understand how it works.

What you'll want to do, in a nutshell, is copy your current code, except change all the control and capture/compare registers.. (I.e. if you're using, say CCR0 now, you'll have to switch to use CCR1 and it's associated control registers and interrupt vector.. So for two uarts, you'll have two chunks of software, one using CCR0 and another CCR1).. Just remember that you have to change a bunch of registers for each CCR.
By naz
#73132
i'll try and i'll let u know
By naz
#73233
Any one have two software uart example program in msp430
By theatrus
#73234
No.
By naz
#73246
[quote="leon_heller"]I'd use a chip with a hardware UART, and do the other one in software.

Leon[/quote]

could u please send me the code which has hardware uart and software uart
User avatar
By leon_heller
#73247
Which chip are you using? You should be able to find the code on the TI web site.

Leon
By naz
#73250
i'm using msp430f2232.which has one hardware uart.i tried the TI websit i didn't fine which doesn't has hardware uart and software uart.could u please send me the link or example code
User avatar
By leon_heller
#73253
The hardware UART details are in the user's guide; just write your own code. Why can't you use the software UART code I gave you?

Leon
By naz
#73315
1.i want to know how to mix the hardware uart program and software uart program
2.i have some doubt in hardware setup.
3.here i'm using p1.1-txd and p2.2 -rxd in software uart program,
4.p3.4-UTXD0 and p3.5-URXD0 in hardware uart,
5.my objective is i have take data from gps to pc through microcontroller(MSP430f2232)
6.and i have to send the commands from pc to gps through microcontroller(MSP430f2232).
User avatar
By leon_heller
#73320
Why don't you simply connect the GPS to the PC? You don't need the MSP430.

Leon
By naz
#73329
in between i have check one NMEA message and i have to insert one more message
By naz
#73389
any one can help ?
Last edited by naz on Sat May 23, 2009 12:12 am, edited 1 time in total.
By naz
#73392
Hello all,
Here i have enclosed the code which i'm using.This is communication between gps to pc through msp430,now i want to change it means
1. i want to receive data through software uart from gps to pc through msp
2. i wan to transfer data from pc to gps using hardware uart
could any one can help me.

#include <msp430x14x.h>
#include<stdio.h>
#include "stdarg.h"

#define RXD 0x04 // RXD on P2.2
#define TXD 0x02 // TXD on P1.1

#define Bitime_5 52 // ~ 0.5 bit length + small adjustment-(104)
#define Bitime 104 // 8.6 us bit length ~ 115942 baud-(208)
#define DELTA 488 //1953

static unsigned int RXTXData;
unsigned int i=0,j,count=0,index,I=0;
unsigned char BitCnt,buffer[];
static const char string[] = { "***STOP***O\r\n" };

void TX_Byte (void);
void RX_Ready (void);
void Set_DCO (void);
void delay(int a);

void main (void)
{
volatile unsigned int i;
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
BCSCTL1 |= DIVA_3; // ACLK = LFXT1CLK/8
Set_DCO(); // Set DCO

CCTL0 = OUT; // TXD Idle as Mark
TACTL = TASSEL_2 + MC_2; // ACLK, continuous mode
P1SEL = TXD; // P1.1/TA0 for TXD function
P1DIR = TXD; // TXD output on P1
P2SEL = RXD; // P2.2/TA0 as RXD input

P6SEL = 0x00; // Select P6 port as I/O
P6DIR = 0xFF; // Set P6 port to Output direction
P6OUT = 0x10;
while(1)
{

for (index=0;index<250;index++)
{
RX_Ready();
_BIS_SR(LPM3_bits+GIE);
buffer[index] = RXTXData;
}

for (index=0;index<225;index++)
{

RXTXData =buffer[index];
TX_Byte();
i = 10;
do (i--);
while (i != 0);
}
RXTXData=0x0D;
TX_Byte();

}

}

// 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
//printf("%s",RXTXData);
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 = CM_2 + CCIS0+ OUTMOD0 + CAP + CCIE ; // Sync, Neg Edge, Cap

}

void Set_DCO (void) // Set DCO to selected frequency
{
unsigned int Compare, Oldcapture = 0;

CCTL2 = CM_1 + CCIS_1 + CAP; // CAP, ACLK
TACTL = TASSEL_2 + MC_2 + TACLR; // SMCLK, cont-mode, clear

while (1)
{
while (!(CCIFG & CCTL2)); // Wait until capture occured
CCTL2 &= ~CCIFG; // Capture occured, clear flag
Compare = CCR2; // Get current captured SMCLK
Compare = Compare - Oldcapture; // SMCLK difference
Oldcapture = CCR2; // Save current captured SMCLK
if (DELTA == Compare) break; // If equal, leave "while(1)"

else if (DELTA < Compare)
{
DCOCTL--;
if (DCOCTL == 0xFF) // DCO is too fast, slow it down
{
if (!(BCSCTL1 == (XT2OFF + DIVA_3)))
BCSCTL1--; // Did DCO role under?, Sel lower RSEL
}
}
else
{
DCOCTL++; // DCO is too slow, speed it down
if (DCOCTL == 0x00)
{
if (!(BCSCTL1 == (XT2OFF + DIVA_3 + 0x07)))
BCSCTL1++; // Did DCO role over? Sel higher RSEL
}
}
}

CCTL2 = 0; // Stop CCR2
TACTL = 0; // Stop Timer_A
}

// Timer A0 interrupt service routine
#pragma vector=TIMERA0_VECTOR
__interrupt 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;
_BIC_SR_IRQ(SCG1 + SCG0);
}

else
{
RXTXData = RXTXData >> 1;
if (CCTL0 & SCCI) // Get bit waiting in receive latch
RXTXData |= 0x80;
BitCnt --; // All bits RXed?
if ( BitCnt == 0)
{
CCTL0 &= ~ CCIE; // All bits RXed, disable interrupt
_BIC_SR_IRQ(CPUOFF); // Clear LPM0 bits from 0(SR)
}
}

}
// 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 --;

}

}

}