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.

TM4C123GH6PM: tm4c123gh6pm interface with SIM900

Part Number: TM4C123GH6PM

I am trying to interface sim900 with tm4c123gh6pm using Uart2. i have just tried a very simple code with AT command to get ok response from GSM but so far i am failing to have desired result. can u check my code and guide me further?

#include <stdint.h>
#include<Tm4C123GH6PM.H>
void PLL_Init(void);
void UART2_Init(void);
void UartWrite(char*pstr);
unsigned char Receiver(void);
void Transmitter(unsigned char data);
int main(void){
unsigned char command;
PLL_Init();
UART2_Init();
UartWrite("this program writes");
UartWrite("AT");
}
void UART2_Init(void){
SYSCTL->RCGCUART|=0X00000004;
SYSCTL->RCGCGPIO|=0X00000008;
UART2->CTL&=~0X00000002;
UART2->IBRD=43; //----Setting Baud Rate 115200
UART2->FBRD=26;
UART2->LCRH=0X00000070;
UART2->CTL|=0X00000002;
GPIOD->AFSEL|=0XC0;
GPIOD->DEN|=0XC0;
GPIOD->PCTL=(GPIOC->PCTL&0XFFFFFF00)+0X0000000C0;
GPIOD->AMSEL&=~0XC0;
GPIOD->DIR |=0X80;
}
void PLL_Init(void) {
SYSCTL->RCC2|=0X80000000;
SYSCTL->RCC2|=0X00000800;
SYSCTL->RCC2=(SYSCTL->RCC2&~0X000007C0)+0X00000540;
SYSCTL->RCC2&=~0X80000070;
SYSCTL->RCC2&=~0X80002000;
SYSCTL->RCC2|=0X40000000;
SYSCTL->RCC2=(SYSCTL->RCC2&~0X1FC00000)+(4<<22);
while((SYSCTL->RIS&0X00000040)==0){};
SYSCTL->RCC2&=~0X00000800;
}

void UartWrite(char*pstr){
while(*pstr !=0){
Transmitter(*pstr++);
} }
unsigned char Receiver(void){
while((UART1->FR&0X01)!=0){};
return UART1->DR&0XFF;
}
void Transmitter(unsigned char data){
while((UART1->FR&0X20)!=0){};
UART1->DR=data;
}

  • Ahmad,
    My suggestion (and likely from other colleagues and from vendor as well) is:
    Delete all this Direct Register coding, and use Tivaware functions to configure your UART.
    You will achieve your goal in a much clearer manner, and we will be able to help if something goes off.
    Regards
    Bruno
  • how can i get Tivaware functions? can u give me some link or hint for it?
  • Sure, just go into www.ti.com/tivaware
    Install Tivaware in your PC.
    Go into the /docs folder, there is a VERY important User Guide there, called SW-TM4C-DRL-UG. That will be your Bible for doing almost everything with TM4C microcontrollers!
    This page also gives some basic hints: docs.google.com/.../
    Regards
    Bruno