bakiyaraj
Newbie level 4
- Joined
- May 10, 2013
- Messages
- 5
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,359
target16f877a, compiler hitech c ...couldnt send ctrlz to send sms it giving arrow mark when i send ox1a...please help sort this out thanks for your time guys
#include<htc.h>
#ifndef _XTAL_FREQ
#define _XTAL_FREQ 11059200
#endif
void tx(unsigned char);
void stx(unsigned const char*);
void gsmsend(unsigned char*);
void uart_init(void);
unsigned char *text="STATUS OF THE DEVICE";
unsigned char *cmd_sendsms="AT+CMGS=";
unsigned char *mobile_no="09845138163";
unsigned char enter=0x0D;
unsigned char ctrlz=0x1A;
unsigned char newline=0x0A;
void main()
{
uart_init();
__delay_ms(7000);
gsmsend(text);
while(1);
}
void tx(unsigned char t)
{
TXREG=t;
while(PIR1bits.TXIF == 0);
PIR1bits.TXIF = 0;
}
void stx(unsigned const char *s)
{
while(*s)
{
tx(*s);
while(PIR1bits.TXIF == 0);
PIR1bits.TXIF = 0;
s++;
}
}
void gsmsend(unsigned char *string)
{
//puts("AT");
//putch(0x0D);
//tx(newline);
stx("AT");tx(enter);tx(newline);
__delay_ms(1000);
stx("AT+CMGF=1");tx(enter);tx(newline);
__delay_ms(1000);
stx(cmd_sendsms);
__delay_ms(1000);
tx(0x22);
__delay_ms(2);
stx(mobile_no);
__delay_ms(2);
tx(0x22);
__delay_ms(2);
tx(enter);
__delay_ms(2);
tx(newline); //goto next line
__delay_ms(2);
stx(string);
__delay_ms(5000);
tx(newline);
tx(enter);
tx(ctrlz);
__delay_ms(1000);
}
void uart_init(void)
{
TRISC7 = 1;
TRISC6 = 0;
//TRISC =0x81;
SPBRG = 71; // BAUD RATE; 9600 with 11.0592mhz 71 IS DECIMAL; HIGH SPEED
//SPBRG = 5; // 115200 BRGH = 1; 11.0592 Mhz
// SPBRG = 129; // 9600 brgh = 1; 20 Mhz
// SPBRG = 64; // 19200 brgh = 1; 20 Mhz
TXSTA = 0x24;
RCIE =1 ; GIE =1; PEIE =1;
RCSTA = 0x90;
}
#include<htc.h>
#ifndef _XTAL_FREQ
#define _XTAL_FREQ 11059200
#endif
void tx(unsigned char);
void stx(unsigned const char*);
void gsmsend(unsigned char*);
void uart_init(void);
unsigned char *text="STATUS OF THE DEVICE";
unsigned char *cmd_sendsms="AT+CMGS=";
unsigned char *mobile_no="09845138163";
unsigned char enter=0x0D;
unsigned char ctrlz=0x1A;
unsigned char newline=0x0A;
void main()
{
uart_init();
__delay_ms(7000);
gsmsend(text);
while(1);
}
void tx(unsigned char t)
{
TXREG=t;
while(PIR1bits.TXIF == 0);
PIR1bits.TXIF = 0;
}
void stx(unsigned const char *s)
{
while(*s)
{
tx(*s);
while(PIR1bits.TXIF == 0);
PIR1bits.TXIF = 0;
s++;
}
}
void gsmsend(unsigned char *string)
{
//puts("AT");
//putch(0x0D);
//tx(newline);
stx("AT");tx(enter);tx(newline);
__delay_ms(1000);
stx("AT+CMGF=1");tx(enter);tx(newline);
__delay_ms(1000);
stx(cmd_sendsms);
__delay_ms(1000);
tx(0x22);
__delay_ms(2);
stx(mobile_no);
__delay_ms(2);
tx(0x22);
__delay_ms(2);
tx(enter);
__delay_ms(2);
tx(newline); //goto next line
__delay_ms(2);
stx(string);
__delay_ms(5000);
tx(newline);
tx(enter);
tx(ctrlz);
__delay_ms(1000);
}
void uart_init(void)
{
TRISC7 = 1;
TRISC6 = 0;
//TRISC =0x81;
SPBRG = 71; // BAUD RATE; 9600 with 11.0592mhz 71 IS DECIMAL; HIGH SPEED
//SPBRG = 5; // 115200 BRGH = 1; 11.0592 Mhz
// SPBRG = 129; // 9600 brgh = 1; 20 Mhz
// SPBRG = 64; // 19200 brgh = 1; 20 Mhz
TXSTA = 0x24;
RCIE =1 ; GIE =1; PEIE =1;
RCSTA = 0x90;
}