Hello,
I need to use UART1 to send AT command to Sim800A module but it doesn't work. I know it because I didn't receive the message from my sim module. I need your help, I have to finish this project at the end of the week. It's urgent. This is my code:
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include "inc/tm4c123gh6pm.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"
void Delay_ms(int t)
{
SysCtlDelay(SysCtlClockGet()/(3*1000/t));
}
void sendStr(char *str)
{
while(*str)
{
UARTCharPut(UART1_BASE,*str);
str++;
}
}
int main(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
GPIOPinConfigure(GPIO_PCTL_PB0_U1RX);
GPIOPinConfigure(GPIO_PCTL_PB1_U1TX);
GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
UARTConfigSetExpClk(UART1_BASE,SysCtlClockGet(),9600,(UART_CONFIG_WLEN_8 |UART_CONFIG_STOP_ONE|UART_CONFIG_PAR_NONE));
sendStr("AT\n");
Delay_ms(200);
sendStr("AT+CMGF=1\n");
Delay_ms(200);
sendStr("AT+CMGS=\"0944353095\"\n");
Delay_ms(200);
sendStr("abcde\n");
Delay_ms(200);
UARTCharPutNonBlocking(UART1_BASE,26);
Delay_ms(200);
}