So I’ve set up the interface between a 169 and an Iridium modem. I am using the UART to communicate with the modem via TX and RX. AT commands are used to control the modem. Right now the modem is set to echo back any character that it has received. The modem will also return “OK” when it has received “AT\r”. I’ve set up some code to print “AT” on the terminal I/O of the debugger when the modem echoes back “AT”. When I send the carriage return the modem spits back “OK”. I can’t figure out a way to detect that this “OK” has been sent by the modem since I can only read one character at a time from the RXBUF. Has anyone successfully programmed a uC similar to this with the use of AT commands that could give some helpful advice?
Here is the code used to detect the echoed characters:
#include <msp430x16x.h>
#include <stdio.h>
//static char string1[] = { “AT+En=0\r” };
//static char string1[] = { “A” };
static char string1[] = { “AT\r” };
char i;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog
P3SEL = 0x30; // P3.4,5 = USART0 TXD/RXD
ME1 |= UTXE0 + URXE0; // Enabled USART0 TXD/RXD
UCTL0 |= CHAR; // 8-bit character, SWRST=1
UTCTL0 |= SSEL0; // UCLK = ACLK
UBR00 = 0x03; // 9600 from 32.768 kHz
UBR10 = 0x00; //
UMCTL0 = 0x4A; // Modulation
UCTL0 &= ~SWRST; // Initialize USART state machine
IE1 |= URXIE0; // Enable USART0 RX interrupt
IFG1 &= ~UTXIFG0; // Clear inital flag on POR
while(1){
i = 0;
while (i < sizeof string1-1)
{
TXBUF0 = string1[i++];
}
}
}
// UART0 RX ISR
#pragma vector=UART0RX_VECTOR
__interrupt void usart0_rx (void)
{
if (RXBUF0 == ‘A’) // ‘A’ received?
{
printf (“A”);
}
if (RXBUF0 == ‘T’) // ‘T’ received?
{
printf (“T\n”);
}
}