PIC Vietnam

Go Back   PIC Vietnam > Truyền thông > Giao tiếp cổng COM và LPT

Tài trợ cho PIC Vietnam
Trang chủ Đăng Kí Hỏi/Ðáp Thành Viên Lịch Tìm Kiếm Bài Trong Ngày Ðánh Dấu Ðã Ðọc Vi điều khiển

Giao tiếp cổng COM và LPT RS232, RS485 và LPT là những giao tiếp cơ bản và kinh điển khi mới học về vi điều khiển...

 
 
Ðiều Chỉnh Xếp Bài
Prev Previous Post   Next Post Next
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
 

Ðiều Chỉnh
Xếp Bài

Quyền Sử Dụng Ở Diễn Ðàn
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is Mở
Smilies đang Mở
[IMG] đang Mở
HTML đang Tắt

Chuyển đến


Múi giờ GMT. Hiện tại là 10:04 AM.


Được sáng lập bởi Đoàn Hiệp
Powered by vBulletin®
Page copy protected against web site content infringement by Copyscape
Copyright © PIC Vietnam