Try ATS0 = n ; n can be any value like 2 , 3 this will let you automatically answer your Call
suppose ATS0 = 3 ; // That means after 3 ring detection the call will be automatically received
Also if you don't want to receive automatically then do one thing Check for The RING String and apply a condition like if Ring Is detected and Some Button is Pressed then MCU send "ATA\r" to receive the Call
#define _XTAL_FREQ 4000000L
#define HIGH_SPEED 1
#if NINE == 1
#define NINE_BITS 0x40
#else
#define NINE_BITS 0
#endif
#if HIGH_SPEED == 1
#define SPEED 0x4
#else
#define SPEED 0
#endif
#define RX_PIN TRISC7
#define TX_PIN TRISC6
__CONFIG(XT & WDTDIS & PWRTEN & BORDIS & LVPDIS &
DEBUGDIS & UNPROTECT );
void wait(unsigned char msec);
void Tx_string(const char *string);
void Tx_byte(unsigned char byte);
void clearBuffer();
int i;
char buffer[95];
main()
{
TRISC=0b11000000;// Rx pin RC7 only i/p others o/ps including Tx pin
PORTC=0b11000000;
TRISD=0b00000000;
PORTD=0b00000000;
SPBRG = 25;//9600 bud rate
RCSTA = (NINE_BITS|0x90);
TXSTA = (SPEED|NINE_BITS|0x20);
INTCON = 0;
wait(1000);
clearBuffer();
Tx_string("AT\r\n");
while(1){
while(!RCIF)
buffer[i++]=RCREG;
buffer[i]='\0';
for(i=0;buffer[i]!=95;i++)
{
lcd_goto(0x00+i)
lcd_putch(buffer[i]);
wait(30);
}
}
}
void clearBuffer(){
for(i = 0;i < 95;i++)buffer[i] = ' ';
}
void Tx_string(const char *string)
{
while(*string){
TXREG=*string;
while(TRMT==0);
string++;
}
}
void Tx_byte(unsigned char byte)
{
while(TRMT==0);
TXREG=byte;
}
void wait(unsigned char msec)
{
unsigned int i,j;
for(i=0;i<=msec;i++)
{
for(j=0;j<=1000;j++);
}
}
what you mean by EUSART Receive Interrupts please explain..I think you have to use UART Receive Interrupts to get the response and parse it using some Pointer or Array and then print it to the LCD ,
I have done that thing but using AVR not with PIC , So try using EUSART Receive Interrupts
There are two methods to USART receive in PIC Microcontroller
1st is Polling Like getting data in RCREG Register and there is another method to use it via Interrupts to enable
the Interrupts PIE bits or like that Has to be given a HIGH Logic to enable Interrupts
EUSART is nothing but its enhanced USART nothing it's USART only dud
Like in AVR I will tell you
If i give High Logic to RXCIE bit then UART Receive Interrupt is Enabled
then an algo is that code will jump to Interrupt Service Routine Function
[CODE] while(!RCIF)
buffer[i++]=RCREG;
buffer[i]='\0';
for(i=0;buffer[i]!=95;i++)
{
lcd_goto(0x00+i)
lcd_putch(buffer[i]);
wait(30);
}
Use ISR to receive serial data and use strstr() or memcmp() functions to test the response.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 #ifndef _SERIAL_H_ #define _SERIAL_H_ #define _XTAL_FREQ 4000000L //#ifndef _SERIAL_H_ #define _SERIAL_H_ #define BAUD 9600 #define FOSC 4000000L #define NINE 0 /* Use 9bit communication? FALSE=8bit */ #define DIVIDER ((int)(FOSC/(16UL * BAUD) -1)) #define HIGH_SPEED 1 #if NINE == 1 #define NINE_BITS 0x40 #else #define NINE_BITS 0 #endif #if HIGH_SPEED == 1 #define SPEED 0x4 #else #define SPEED 0 #endif #define RX_PIN TRISC7 #define TX_PIN TRISC6 /* Serial initialization */ #define init_comms()\ RX_PIN = 1; \ TX_PIN = 1; \ SPBRG = DIVIDER; \ RCSTA = (NINE_BITS|0x90); \ TXSTA = (SPEED|NINE_BITS|0x20) #endif __CONFIG(XT & WDTDIS & PWRTEN & BORDIS & LVPDIS & main() { INTCON = 0; init_comms(); wait(10); lcd_init(); wait(10); clearBuffer(); lcd_clear(); i=0; Tx_string("AT\r"); while(RCIF){ buffer[i]=RCREG; i++; } buffer[i]= '\0'; for(i=0;buffer[i]!='\0';i++) { buffer[i]+= 0x30; lcd_goto(0x00+i); wait(10); lcd_putch(buffer[i]); wait(50); } while(1); void clearBuffer() { for(i = 0;i < 95;i++)buffer[i] = ' '; }
Where is your ISR? INTCON should be 0xC0.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?