ADGAN
Full Member level 5
- Joined
- Oct 9, 2013
- Messages
- 295
- Helped
- 4
- Reputation
- 8
- Reaction score
- 4
- Trophy points
- 18
- Activity points
- 1,837
Hi! I want to interface the TC35 GSM modem to PIC18F45K22. I tested my GSM modem in Hyper terminal its working fine. The breakout board has a built-in MAX232 IC. So I only need to connect it to the TX1 and RX1 pins of the PIC. I want to know whether I could simulate this in Proteus without connecting the GSM modem, just want to make sure that AT commands are getting out. I tried to do it. But nothing displays on the virtual terminal. The program even didn't run in the hardware too. I tried many other codes as well which are written in MikroC. But nothing worked.
This is my code:
This is my code:
Code:
#include <usart.h>
void UART2_Write_Text(char text[]){
unsigned int i = 0;
while(text[i])Write2USART(text[i++]);
}
void GSM_Send(char min){
unsigned char spbrg = 25;
unsigned char Command_AT[] = "AT\r\n";
unsigned char Command_CMGF[] = "AT+CMGF=1\r\n";
unsigned char Command_CMGS[] = "AT+CMGS=\"+94774944647\"\r\n";
unsigned char msg01[] = "Hello!";
unsigned char CtrlZ = 0x1A;
unsigned int i = 0,j = 0;
TXSTA2bits.TXEN = 1;// Activate Transmission
TXSTA2bits.SYNC = 0;//Asynchronus full duplex
RCSTA2bits.SPEN = 1; // To activate serial port (Tx and Rx pins)
RCSTA2bits.CREN = 1; // Activate Reception
while(1){
Init_Delay();Init_Delay();Init_Delay();Init_Delay();Init_Delay();
Open2USART(USART_TX_INT_OFF | USART_RX_INT_OFF | USART_ASYNCH_MODE | USART_EIGHT_BIT | USART_CONT_RX | USART_BRGH_LOW, 207);
baud2USART (BAUD_8_BIT_RATE | BAUD_AUTO_OFF);
Init_Delay(); //1 sec delay
while(Busy2USART());
UART2_Write_Text(Command_AT);
Init_Delay(); //1 sec delay
UART2_Write_Text(Command_CMGF);
Init_Delay();Init_Delay(); //2 sec delay
UART2_Write_Text(Command_CMGS);
Init_Delay();Init_Delay();Init_Delay();Init_Delay();Init_Delay(); //5 sec delay
UART2_Write_Text(msg01);
Init_Delay(); //0.3 sec delay
Write2USART(CtrlZ);
Write2USART(13);
Write2USART(10);
}
}