hello i am trying to interface gsm module with my launchap tm4c123gxl but my code didn't work correctly
here is the code
#include <stdint.h>
#include <stdbool.h>
#include "hw_ints.h"
#include "hw_memmap.h"
#include "debug.h"
#include "fpu.h"
#include "gpio.h"
#include "interrupt.h"
#include "pin_map.h"
#include "rom.h"
#include "sysctl.h"
#include "uart.h"
#include "utils/uartstdio.h"
#include "tm4c123gh6pm.h"
volatile uint32_t ui32Loop;
unsigned char ch3;
unsigned char imei[16];
unsigned char ip[16];
void pdp_connect(void);
void Tx_String(unsigned char *str);
void Tx_Char(unsigned char);
unsigned char Rx_Char(void);
void ledon(void);
void ledoff(void);
#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif
/
// code for The UART interrupt handler.
void UARTIntHandler(void)
{
uint32_t ui32Status;
// Get the interrrupt status.
ui32Status = ROM_UARTIntStatus(UART1_BASE, true);
// Clear the asserted interrupts.
ROM_UARTIntClear(UART1_BASE, ui32Status);
// Loop while there are characters in the receive FIFO.
while(ROM_UARTCharsAvail(UART1_BASE))
{
// Read the next character from the UART and write it back to the UART.
ROM_UARTCharPutNonBlocking(UART1_BASE, ROM_UARTCharGetNonBlocking(UART1_BASE));
}
}
//code to configure uart1
void ConfigureUart(void){
uint8_t rxchar;
// Enable UART1
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
SysCtlDelay(5);
// Enable the GPIO Peripheral used by the UART.
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
// Enable processor interrupts.
ROM_IntMasterEnable();
// Set GPIO B0 and B1 as UART pins.
ROM_GPIOPinConfigure(GPIO_PB0_U1RX);
ROM_GPIOPinConfigure(GPIO_PB1_U1TX);
ROM_GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
// Configure the UART for 115,200, 8-N-1 operation.
ROM_UARTConfigSetExpClk(UART1_BASE, ROM_SysCtlClockGet(), 115200,(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
// Enable the UART interrupt.
ROM_IntEnable(INT_UART1);
ROM_UARTIntEnable(UART1_BASE, UART_INT_RX | UART_INT_RT);
}
// code to transmit string
void Tx_String(unsigned char *str)
{
while(*str)
{
UARTCharPut(UART1_BASE,*str);
str++;
}
}
void pdp_connect(void){
unsigned int i;
do
{
Tx_String("ATE0");// turn of echo mode off
UARTCharPut(UART1_BASE,'\r');// carriage return
UARTCharPut(UART1_BASE,'\n');
ch3=UARTCharGet(UART1_BASE);
}while(ch3!='0');
do
{
Tx_String("ATV0");// turn of echo mode off
UARTCharPut(UART1_BASE,'\r');// carriage return
UARTCharPut(UART1_BASE,'\n');
ch3=UARTCharGet(UART1_BASE);
}while(ch3!='0');
do
{
Tx_String("At+GSN");// turn of echo mode off
UARTCharPut(UART1_BASE,'\r');
UARTCharPut(UART1_BASE,'\n');
for(i=0;i<=14;i++){
imei[i]=UARTCharGet(UART1_BASE);
}
}while(i!=15);
//Tx_String(imei);
//UARTCharPut(UART1_BASE,'\r');
do
{
Tx_String("AT+QIMUX=1");//
UARTCharPut(UART1_BASE,'\r');// carriage return
ch3=UARTCharGet(UART1_BASE);
}while(ch3!='0'||ch3!='o'||ch3!='O'|| ch3!='k'||ch3!='K');
do
{
Tx_String("AT+QIACT");//
UARTCharPut(UART1_BASE,'\r');// carriage return
UARTCharPut(UART1_BASE,'\n');
ch3=UARTCharGet(UART1_BASE);
}while(ch3!='0');
do
{
Tx_String("AT+QILOCIP");//
UARTCharPut(UART1_BASE,'\r');// carriage return
UARTCharPut(UART1_BASE,'\n');
for(i=0;i<=14;i++){
ip[i]=UARTCharGet(UART1_BASE);
}}while(i!=15);
}
void ledon(void){
GPIO_PORTF_DATA_R |= 0x04;
}
void ledoff(void){
GPIO_PORTF_DATA_R &= ~(0x04);
}
// main.c
int main(void)
{
// Enable lazy stacking for interrupt handlers.
ROM_FPUEnable();
ROM_FPULazyStackingEnable();
// Set the clocking to run directly from the crystal.
ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
// Enable the GPIO port that is used for the on-board LED.
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlDelay(5);
GPIO_PORTF_DIR_R = 0x04;
GPIO_PORTF_DEN_R = 0x04;
ledon();
ConfigureUart();
pdp_connect();
return 0;
}