Hello everyone,
At I said, I tried interface my TivaC Kit TM4C123GXL with Module Sim 900.
But I never get my right result. It always return "ERROR" from module sim.
This is my code.
#include <stdint.h> #include <stdbool.h> #include <stdio.h> #include <string.h> #include "inc/hw_ints.h" #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "driverlib/gpio.h" #include "driverlib/interrupt.h" #include "driverlib/pin_map.h" #include "driverlib/sysctl.h" #include "driverlib/uart.h" void UART_Send(uint32_t uart,char* mess){ while(*mess!=0){ UARTCharPut(uart, *mess); *mess++; } } void UARTIntHandler2(void) { uint32_t ui32Status; ui32Status = UARTIntStatus(UART2_BASE, true); //get interrupt status UARTIntClear(UART2_BASE, ui32Status); //clear the asserted interrupts UART_Send(UART2_BASE,"AT\r"); SysCtlDelay(SysCtlClockGet()/100); if(UARTCharsAvail(UART2_BASE)){ printf("%c",UARTCharGet(UART2_BASE)); } } int main(void) { SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART2); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); GPIOPinConfigure(GPIO_PD6_U2RX); GPIOPinConfigure(GPIO_PD7_U2TX); GPIOPinTypeUART(GPIO_PORTD_BASE, GPIO_PIN_6 | GPIO_PIN_7); UARTConfigSetExpClk(UART2_BASE, SysCtlClockGet(), 9600,(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); IntMasterEnable(); IntEnable(INT_UART2); //enable the UART interrupt UARTIntEnable(UART2_BASE, UART_INT_RX | UART_INT_RT); UART_Send(UART2_BASE,"AT\r"); SysCtlDelay(SysCtlClockGet()/100); while(1){ } }
Please help me, because this is my first time I work with this, not my major.