EmbeddedRelated.com
Forums

S/W UART Problem on MSP430F4250

Started by "Nirosh P. Wijayaratne" June 29, 2007
Hello,

I am trying to make p1.3 on MSP430F4250 to work as a Uart TX. The attached code configures the p1.3 using Timer_A3.
Attached code supposed to output 0x55 on P1.3 of MSP430F4250. But the output on the pin always stays at high. I tried sending out 0x00 but still i only see a high on the output.

Any words of wisdom appreciated.

Thanks

Nirosh

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

#include
#include "adcdriver.h"

#define TXD 0x08 // TXD on P1.0

// Conditions for 9600 Baud SW UART, SMCLK = 8MHz

#define Bitime_5 417 // ~ 0.5 bit length + small adjustment
#define Bitime 834 // 8.6 us bit length ~ 115942 baud

unsigned int RXTXData;
unsigned char BitCnt;

void TX_Byte(void);
void RX_Ready(void);

unsigned char str[]= "U";
void main (void)
{
unsigned int j,i;
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
FLL_CTL0 |= DCOPLUS + XCAP14PF; // DCO+, Configure load caps
SCFI0 |= FN_4; // x2 DCO frequency, 8MHz nominal
SCFQCTL = 121; // (121+1) x 32768 x 2 = 7.99 MHz
// TXD Idle as Mark
TACTL = TASSEL_2 + MC_2; // SMCLK, continuous mode
P1SEL |= TXD ; // P1.0/1 TA0 for TXD/RXD function
P1DIR |= TXD; // TXD output on P1
CCTL2 = OUT;
_BIS_SR(GIE); // Enter LPM0 Until character RXed
// Mainloop
for (;;)
{
RXTXData = 0x55;
TX_Byte();

}
}
// Function Transmits Character from RXTXData Buffer
void TX_Byte (void)
{
BitCnt = 0xA; // Load Bit counter, 8data + ST/SP
CCR2 = TAR; // Current state of TA counter
CCR2 += Bitime; // Some time till first bit
RXTXData |= 0x100; // Add mark stop bit to RXTXData
RXTXData = RXTXData << 1; // Add space start bit
CCTL2 &= ~ CAP;
CCTL2 |= OUTMOD0 + CCIE; // TXD = mark = idle
while ( CCTL2 & CCIE ); // Wait for TX completion
}

#pragma vector=TIMERA1_VECTOR
__interrupt void Timer_A1 (void)
{
CCR2 += Bitime; // Add Offset to CCR0
if ( BitCnt == 0)
CCTL2 &= ~ CCIE; // All bits TXed, disable interrupt
else
{
CCTL2 |= OUTMOD2; // TX Space
if (RXTXData & 0x01)
CCTL2 &= ~ OUTMOD2; // TX Mark
RXTXData = RXTXData >> 1;
BitCnt --;
}

Beginning Microcontrollers with the MSP430