KHI LẬP TRÌNH GIAO TIẾP VỚI SIM MÌNH GẶP PHẢI LỖI SAU MONG MỌI NGƯỜI GIÚP ĐỠ?
KHÔNG BIẾT VÌ SAO LẠI BÁO LỖI NÀY NỮA. ĐÂY LÀ CODE VÀ HÌNH:
#include <main.h>
#include <string.h>
#include "PIC16F877A_registers.h"
#use fast_io(A)
#use fast_io(B)
#use fast_io(C)
void Uart_putsf(char *input); // ham gui di 1 chuoi
void Uart_putchar(char input); // ham gui di 1 ki tu
#int_RDA
void RDA_isr(void)
{
}
void main()
{
TRISA = 0xFE;
TRISB = 0x00;
TRISC = 0x80;
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
//vdk gui 1 tin nhan di tu module sim
Uart_putsf("AT+CMGS="); //ma lenh de gui 1 tin nhan
Uart_putsf(34); //ma acsiII cua dau "
Uart_putsf("0123456789"); // so dien thoai ng nhan
Uart_putsf(34); //ma acsiII cua dau "
Uart_putsf(13); // ma cua dau enter </r>
delay_ms(1000); // doi module sim nhan lenh se san sang nhan noi dung tin nhan
Uart_putsf("DEN1 ON"); // noi dung tin nhan
Uart_putsf(0x1A); // ma lenh ket thuc noi dung tin nhan
//neu tin nhan dc gui di thanh cong module sim se gui ve chuoi "OK" neu k no se gui ve "ERROR"
//vdk doc 1 tin nhan tu module sim
Uart_putsf("AT+CMGL="); //ma lenh de doc 1 tin nhan tu module sim
Uart_putsf(34); //"
Uart_putsf("REC UNREAD"); // lenh de doc nhung tin nhan chua dc doc
Uart_putsf(34); //"
Uart_putsf(13); //CR == Enter
delay_ms(1000);
//>>> doi module sim tra noi dung tin nhan ve neu co tin nhan moi chua dc doc
//neu k thi k co noi dung thi bo qua
while(TRUE)
{
};
}
void Uart_putsf(char *input) // ham gui di 1 chuoi
{
int8 i__;
for(i__=0;input[i__]!=0;i__++)Uart_putchar(input[i__]);
}
void Uart_putchar(char input) // ham gui di 1 ki tu
{
while(!(TXSTA & 0x02)); // doi vdk san sang gui 1 ky tu moi
TXREG = input; // ky tu moi dc gan vao thanh ghi de gui di
}