This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

serial port of msp430

Other Parts Discussed in Thread: MSP430F235

I am working with msp430f235. I want to enable to GSM module using serial port and also want to call at a particular number. The code for that I have written is as follows:

#include "msp430f235.h"
const char string1[] = { "ATD07417338415;" };
volatile unsigned int i,j=0;
void main(void)
{
    
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
 BCSCTL1 = CALBC1_1MHZ;                    // Set DCO
  DCOCTL = CALDCO_1MHZ;
  P3SEL = 0x30;                             // P3.4,5 = USCI_A0 TXD/RXD
  UCA0CTL1 |= UCSSEL_2;                     // SMCLK
  UCA0BR0 = 104;                            // 1MHz 9600; (104)decimal = 0x068h
  UCA0BR1 = 0;                              // 1MHz 9600
  UCA0MCTL = UCBRS1 + UCBRS0;                      // Modulation UCBRSx = 3
  UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
  IE2 |= UCA0RXIE;                          // Enable USCI_A0 RX interrupt
  for(i=0;i<16;i++)
  { while (!(IFG2&UCA0TXIFG));                 // USCI_A0 TX buffer ready?
    UCA0TXBUF = string1[i];
     j++;  
  }                                // TX next character   
    
}

But this code contains no error but still not able to call at a particular number after downloading in msp430. why it is happening ? please guide me.

  • First, according to the table in thr users guide, thr modulation for 9600Bd on 1MHz clock is 1, not 3. (so set only UCBRS0, not UCBRS1)

    Then I noticed that he dial string does not contain a CR to finish the command. Most devices with AT /hayes) compatible command set require a CR or even CR/LF to start the execution. THen you send 16 bytes. the string is only 15 bytes. So after the command you send an 0 byte. This is the 16th byte in the sting, yes, but not part of the data you have to send. Usually, when dialiing, any character received after the dial command will immediately abort the dial.

    There is no need to declare i or j volatile. THi sis only necessary if the variables change outside the program flow (e.g. inside an interrupt function, or due to DMA transfers or such).Then the compiler knows that this will happen and will no make any assumptions about the variable state and won't make optimizations.
    In your case, i and j do not require to be volatile, as they are not altered or read outside the program flow. THe compiler can then put them e.g. into a processor register, which makes the code faster and smaller.

    Last, you enable the RX interrupt. Do you have an ISR for this? I fnot, the program will crash and mos tlikely reboot the MSP as soon as a byte comes in.

**Attention** This is a public forum