View Single Post
Old 13-07-2016, 04:47 PM   #8
digan
Đệ tử 1 túi
 
digan's Avatar
 
Tham gia ngày: Jan 2006
Bài gửi: 14
:
Mình làm một ứng dụng đơn giản khởi động mạch nên thì gửi một tin nhắn text đến số ĐT, đã hiệu chỉnh nhiều lần nhưng nó vẫn không thực hiện được, bạn nào có kinhnghiệm kiểm tra lỗi giúp mình với.
Chương trình chính
#include "D:\Dropbox\5.Project\0.LAB\0. PIC\UART\UART\UART Programe\UART Pro_int.h"
#include "SIM900.c"
void main()
{

setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard

GSM_on();
delay_ms(10000);
SIM900_init();
GSM_makeSMS();

while(TRUE)
{

}

}

Chương trình SIM900.c
#define PWR_KEY PIN_C5

void SIM900_init()
{

printf("at\r\n"); // Khoi tao
delay_ms(1000);
printf("at\r\n");
delay_ms(1000);
printf("at\r\n");
delay_ms(1000);
printf("at0\r\n"); //Tat Echo
delay_ms(1000);
printf("AT+IPR=9600");
delay_ms(1000);
printf("at+cmgf=1\r\n"); // Cho phép gui/nhan tin nhan
delay_ms(1000);
printf("at+clip=1\r\n"); // Hien thi thong tin nguoi goi den
delay_ms(1000);
printf("at+CNMI=2,2\r\n"); // Hien thi truc tiep tin nhan
delay_ms(1000);
}
void GSM_on()
{
output_high(PWR_KEY);
delay_ms(1500);
output_low(PWR_KEY);
delay_ms(1000);
}
void GSM_makeSMS()
{
printf("at+cmgs=\"096xxx335\"\r\n");
delay_ms(1000);
printf("test tin nhan !!\n\r"); // Text to reply
putchar(0x1A); // send Ctrl-z
delay_ms(1000);

}
digan vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn