Other Parts Discussed in Thread: MSP430F5239, CC430F6137, MSP-TS430RGC64C, MSP430WARE
Hi
I am trying to port code from a CC430F6137 to a MSP430F5239, I thought I would test the communication protocol's first. The problem is that on the CC430F the UART worked perfectly from then "CC430F61xx Examples. So I tried this method for the MSP430F5239 and am having an issue with sending strings.
Processor: MSP430F5239
Environment: CCS, MSP-TS430RGC64C, RS232 Level Shifter (3V3 -> SERIAL), terminal program to receive data.
OUTPUT from UART:
08:53:14:394 MOUDULE -> PC
ABCDEFGHIJ[03][00]
I know that I have done something incorrect, so any guidance will be appreciated.
<code>
/*------------------------------------------------------------------------------
Standard Defined Libraries
------------------------------------------------------------------------------*/
#include <msp430.h>
#include <string.h>
#include <stdio.h>
/*------------------------------------------------------------------------------
Custom Defined Libraries
------------------------------------------------------------------------------*/
//
/*------------------------------------------------------------------------------
Function Prototypes
------------------------------------------------------------------------------*/
void DebugTxData (char *data); // Print Data to the Debug UART
void MilSecDelay (void); // Milli-Second Counter
void OneSecDelay (void); // One Second Delay
/*------------------------------------------------------------------------------
Global Variables
------------------------------------------------------------------------------*/
char DebugReceivedData [256]; // DEBUG Responses Saved Here
int MilliSecondCounter; // Counter Reg For Milli-Second Delay
int SecondCounter; // Counter Reg for 1 Second Delay
/*------------------------------------------------------------------------------
Local Variables
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
MAIN ROUTINE
* Initialises MCU
------------------------------------------------------------------------------*/
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT to prevent WDT Reset for Start Up
// UART Setup
UCA1CTL1 |= UCSWRST; // **Put state machine in reset**
UCA1CTL1 |= UCSSEL_2; // SMCLK
P4DIR |= BIT4; // Set P4.4 as UART TX output
P4SEL |= BIT4+BIT5; // P4.4,5 = USCI_A0 TXD/RXD
UCA1IRTCTL &= ~UCIREN; // Disable the IR Function
UCA1CTL0 &= ~UCPEN; // No Parity
UCA1CTL0 &= ~UCSPB; // 1 Stop BIT
UCA1CTL0 &= ~UC7BIT; // 8 BITS
UCA1CTL0 &= ~UCMSB; // LSB First
UCA1CTL0 &= ~UCSYNC; // Asynchronous Mode
UCA1CTL0 &= ~UCMODE0; // UART Mode
UCA1BR0 = 9; // 1MHz 115200 (see User's Guide)
UCA1BR1 = 0; // 1MHz 115200
UCA1MCTL |= UCBRS_1 + UCBRF_0; // Modulation UCBRSx=1, UCBRFx=0
UCA1MCTL &= ~UCOS16; // Over sampling Not Selected
UCA1CTL1 &= ~UCSWRST; // **Initialise USCI state machine**
// UCA1IE |= UCRXIE; // Enable USCI_A0 RX interrupt
//
// OneSecDelay(); // Settle the system
DebugTxData ("ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789\r\n\0"); // DEBUG -> System Message
// Continuous LOOP
while(1)
{
; // Loop Here
}
} // End Of Main Routine
/*------------------------------------------------------------------------------
END OF MAIN ROUTINE
------------------------------------------------------------------------------*/
//
/*------------------------------------------------------------------------------
DEBUG UART Send
* Checks Data length in routine
* RETURN: NONE
* PASS: STRING (CHAR)
* CALL: NONE
------------------------------------------------------------------------------*/
void DebugTxData (char *data)
{
// P1OUT ^= BIT6; // Toggle LED for debugging
unsigned int i;
unsigned int size = strlen(data); //get length of data to be sent
for (i = 0; i < size; i++)
{
while (!(UCTXIFG & UCA1IFG)); // Wait UART to finish before next send
UCA1TXBUF = data[i]; // Send out on UART
}
// memset(data, 0, i);
}
/*------------------------------------------------------------------------------
Milli-Second Delay
* RETURN: NONE
* PASS: STRING (CHAR)
* CALL: NONE
------------------------------------------------------------------------------*/
void MilSecDelay (void)
{
for(MilliSecondCounter=0 ; MilliSecondCounter < 1000 ; MilliSecondCounter++)
{
__no_operation(); // Waste Time
}
}
/*------------------------------------------------------------------------------
1 Second Delay
* RETURN: NONE
* PASS: STRING (CHAR)
* CALL: NONE
------------------------------------------------------------------------------*/
void OneSecDelay (void)
{
for(SecondCounter=0 ; SecondCounter < 85 ; SecondCounter++)
{
MilSecDelay (); // ~1 millisecond delay
}
}
/*------------------------------------------------------------------------------
END OF PROGRAM
------------------------------------------------------------------------------*/