kiean
Newbie level 5
I just want to ask who knows how to program a PIC16f88 or PIC16f877a that will sends AT commands to GSM modem whenever an input high is send to any PORTA pins. I have here my code but it doesnt work and i dont know whats wrong.Im not really familiar with these programming stuff.here is my source code but any source code suggestion can be a really big help.
#include <pic.h>
//wrapper for sending char in usart TX port
void tx_char (char c) {
TXREG = c; //place character to usart tx register
}
//wrapper for sending a string in usart TX port
void tx_str (char *s) {
while (*s != '\0') {
while (!TXIF);
tx_char (*s);
s ++;
}
}
void main (void) {
signed long int ctr;
ADCON0 = 0x00; //disable adc functionality
INTCON |= 0xC0; //enable global and peripheral-based interrupts
TRISA = 0xFF; //port a is input
//init usart capabilities
TXSTA |= 0b00100100;
RCSTA |= 0b10010000;
SPBRG = 0x19; //9600 baud
while (1) {
for (ctr = 0; ctr < 0xFF; ctr ++);
tx_str("AT\rAT+CMGF=1\rAT+CMGW=\"+63236805800\"\rmy message.\n+CMGW: 1\rAT+CMSS=1\r+CMSS: 20\r" ) ;
}
}
#include <pic.h>
//wrapper for sending char in usart TX port
void tx_char (char c) {
TXREG = c; //place character to usart tx register
}
//wrapper for sending a string in usart TX port
void tx_str (char *s) {
while (*s != '\0') {
while (!TXIF);
tx_char (*s);
s ++;
}
}
void main (void) {
signed long int ctr;
ADCON0 = 0x00; //disable adc functionality
INTCON |= 0xC0; //enable global and peripheral-based interrupts
TRISA = 0xFF; //port a is input
//init usart capabilities
TXSTA |= 0b00100100;
RCSTA |= 0b10010000;
SPBRG = 0x19; //9600 baud
while (1) {
for (ctr = 0; ctr < 0xFF; ctr ++);
tx_str("AT\rAT+CMGF=1\rAT+CMGW=\"+63236805800\"\rmy message.\n+CMGW: 1\rAT+CMSS=1\r+CMSS: 20\r" ) ;
}
}