hello everyone, im new in pic programming and i want to resolve my problem with the UART.. Im trying to display a message coming from gsm modem to LCD through 877A.. everytime i sent a message to the gsm modem the RCIF is not activated...
hers my code:
#include <pic.h>
#include <stdio.h>
#include "uart.h"
#include "delay.h"
#include "lcd.h"
//Configuration bits
__CONFIG(HS & WDTDIS & LVPDIS & UNPROTECT);
void main()
{
char rcv_data;
char rcv_data_buffer[16];
TRISD7 = 0; //RD7 initialized as output
RD7 = 1; //RD7 is ON..trigger the gsm.
DelayMs(250);
DelayMs(250);
RD7 = 0;
DelayMs(250); /**** delay****/
DelayMs(250); /***wait for the gsm***/
DelayMs(250); /****to be in normal****/
DelayMs(250); /********m
lcd_init(); //Initialize the LCD.
DelayMs(250);
DelayMs(250);
UARTInit(); //Initialize the UART modul
DelayMs(250);
while(1)
{
if(OERR)
{
CREN = 0;
CREN = 1;
}
if(RCIF == 1)
{
rcv_data = (RCREG);
DelayMs(250);
sprintf(rcv_data_buffer,"%c",rcv_data);
DelayMs(250);
lcd_clear();
DelayMs(250);
lcd_puts(rcv_data_buffer);
DelayMs(250);
lcd_puts("God is good");
}
else
{
DelayMs(250);
lcd_clear();
DelayMs(250);
lcd_puts("Jeremiah 29:11");
DelayMs(250);
}
}
}
heres my code under uart init
void UARTInit(void)
{
BRGH = 1; //high-speed
// SPBRG = 25; //9600 baud/s at 4 mhz
SPBRG = 129; //9600 baud/s at 20 mhz
// SPBRG = SPBRG_VAL;
TX9 = 0; //8-bit data
RX9 = 0;
SYNC = 0; //set UART in asynchronouse mode
SPEN = 1; //enable serial port
CREN = 1; //enable continuous receive mode
// RCIE = 1; //enable Rx interrupt
// TXIE = 0; //enable Tx interrupt
TXEN = 1; //enable Transmit
// PEIE = 1; //enable peripheral interrupt
// GIE = 1;
}
tnx in advance.. hope you could help me.. God bless
hers my code:
#include <pic.h>
#include <stdio.h>
#include "uart.h"
#include "delay.h"
#include "lcd.h"
//Configuration bits
__CONFIG(HS & WDTDIS & LVPDIS & UNPROTECT);
void main()
{
char rcv_data;
char rcv_data_buffer[16];
TRISD7 = 0; //RD7 initialized as output
RD7 = 1; //RD7 is ON..trigger the gsm.
DelayMs(250);
DelayMs(250);
RD7 = 0;
DelayMs(250); /**** delay****/
DelayMs(250); /***wait for the gsm***/
DelayMs(250); /****to be in normal****/
DelayMs(250); /********m
lcd_init(); //Initialize the LCD.
DelayMs(250);
DelayMs(250);
UARTInit(); //Initialize the UART modul
DelayMs(250);
while(1)
{
if(OERR)
{
CREN = 0;
CREN = 1;
}
if(RCIF == 1)
{
rcv_data = (RCREG);
DelayMs(250);
sprintf(rcv_data_buffer,"%c",rcv_data);
DelayMs(250);
lcd_clear();
DelayMs(250);
lcd_puts(rcv_data_buffer);
DelayMs(250);
lcd_puts("God is good");
}
else
{
DelayMs(250);
lcd_clear();
DelayMs(250);
lcd_puts("Jeremiah 29:11");
DelayMs(250);
}
}
}
heres my code under uart init
void UARTInit(void)
{
BRGH = 1; //high-speed
// SPBRG = 25; //9600 baud/s at 4 mhz
SPBRG = 129; //9600 baud/s at 20 mhz
// SPBRG = SPBRG_VAL;
TX9 = 0; //8-bit data
RX9 = 0;
SYNC = 0; //set UART in asynchronouse mode
SPEN = 1; //enable serial port
CREN = 1; //enable continuous receive mode
// RCIE = 1; //enable Rx interrupt
// TXIE = 0; //enable Tx interrupt
TXEN = 1; //enable Transmit
// PEIE = 1; //enable peripheral interrupt
// GIE = 1;
}
tnx in advance.. hope you could help me.. God bless