trophy
Newbie level 2
Hey guys. I'm working on this design project and I'm having trouble using my GSM modem (SIM900D) to send a text message. I'm using PIC16F877A as my MCU and I'm using it's UART functionality.
TX (MCU) - RX (modem)
RX (MCU) - TX (modem)
Here's my code. I'm also using PIC C Compiler.
I put an LED at PIN A2 to see if my code reaches the end of the main function. It does light up after some delay and I think there must be something wrong with my code in the middle. Could you guys help me with this? I would greatly appreciate your help.
TX (MCU) - RX (modem)
RX (MCU) - TX (modem)
Here's my code. I'm also using PIC C Compiler.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 #include <stdio.h> #include <pic.h> #include <16F877A.h> #device adc=16 #FUSES NOWDT //No Watch Dog Timer #FUSES HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD) #FUSES NOBROWNOUT //No brownout reset #use delay(clock=20000000) #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bi ts=8,stream=PORT1) void main() { SET_TRIS_A(0x01); //bit 0 as input //i put a 10-second delay in here for the GSM Modem to initialize printf("AT+CMGF=1\r\n"); //set to text mode printf("AT+CMGS=\"xxxxxxxxxxx\"\r\n"); //put your number here printf("this is a message!"); putchar(0x1A); output_high(PIN_A2); }
I put an LED at PIN A2 to see if my code reaches the end of the main function. It does light up after some delay and I think there must be something wrong with my code in the middle. Could you guys help me with this? I would greatly appreciate your help.
Last edited by a moderator: