i really need help about our project...
we have pic16f877 to sniff the nokia 6210's inbox message and outbox message... but nothing happen...can any1 help me about our program and hardware...
we connect the PIC TX to Max232 TXin then the Max232 TXout to the DB9 Male RX
then the PIC RX to Max232 RXout then the Max232 RXin to the DB9 Male TX..is this correct then we used 18.432MHz crystal and FBus Cable
here's the program..it will just acknowledge to the lcd that there is a response from the phone that the pic requested...
#include <pic.h>
#define CMDLEN_GETFOLDERSTAT 18
void sendbyte(unsigned char);
void receive();
void transmit();
void initUART();
void LCD_data(unsigned char);
void LCD_inst(unsigned char);
void initLCD();
void delay(int);
unsigned char CMD_GETFOLDERSTAT[] =
{
0x1E, 0x00, 0x0C, 0x14, 0x00, 0x09, 0x00, 0x01, 0x01,
0x6B, 0x00, 0x0F, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00
};
unsigned char rcdata;
unsigned char flag;
void main(void)
{
int count = 0;
unsigned char temp = '1';
__CONFIG( 0x3d31 );
TRISA = 0x00;
TRISB = 0x00;
TRISC = 0xC0;
TRISD = 0x01;
initLCD();
initUART();
while( RD0 )
continue;
LCD_data( temp++ );
delay(2000);
transmit();
for( count = 0; count < CMDLEN_GETFOLDERSTAT; count++ )
{
sendbyte( CMD_GETFOLDERSTAT[count] );
}
LCD_data( temp++ );
delay( 2000 );
receive();
for( ;; )
{
if( flag == 1 )
{
if( rcdata == 0x1e )
LCD_data( temp++ );
flag = 0;
}
}
}
void initUART()
{
SPBRG = 9;
RCIE = 1;
PEIE = 1;
GIE = 1;
}
void sendbyte( unsigned char tmp )
{
while( !TXIF )
continue;
TXREG = tmp;
}
void transmit()
{
TXSTA = 0x24;
RCSTA = 0x80;
}
void receive()
{
TXSTA = 0x04;
RCSTA = 0x90;
}
void interrupt serial_isr()
{
if(RCIF && RCIE)
{
rcdata = RCREG;
flag = 1;
}
}
void initLCD()
{
delay(2000);
LCD_inst(0x38);
LCD_inst(0x06);
LCD_inst(0x0F);
LCD_inst(0x01);
}
void LCD_inst(unsigned char x)
{ delay(1000);
PORTB = x;
RA0 = 0;
RA1 = 0;
delay(1500);
RA1 = 1;
}
void LCD_data(unsigned char data)
{ delay(2000);
PORTB =data;
RA0 = 1;
RA1 = 0;
delay(2000);
RA1 = 1;
}
void delay(int x)
{
while(x--);
}
we have pic16f877 to sniff the nokia 6210's inbox message and outbox message... but nothing happen...can any1 help me about our program and hardware...
we connect the PIC TX to Max232 TXin then the Max232 TXout to the DB9 Male RX
then the PIC RX to Max232 RXout then the Max232 RXin to the DB9 Male TX..is this correct then we used 18.432MHz crystal and FBus Cable
here's the program..it will just acknowledge to the lcd that there is a response from the phone that the pic requested...
#include <pic.h>
#define CMDLEN_GETFOLDERSTAT 18
void sendbyte(unsigned char);
void receive();
void transmit();
void initUART();
void LCD_data(unsigned char);
void LCD_inst(unsigned char);
void initLCD();
void delay(int);
unsigned char CMD_GETFOLDERSTAT[] =
{
0x1E, 0x00, 0x0C, 0x14, 0x00, 0x09, 0x00, 0x01, 0x01,
0x6B, 0x00, 0x0F, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00
};
unsigned char rcdata;
unsigned char flag;
void main(void)
{
int count = 0;
unsigned char temp = '1';
__CONFIG( 0x3d31 );
TRISA = 0x00;
TRISB = 0x00;
TRISC = 0xC0;
TRISD = 0x01;
initLCD();
initUART();
while( RD0 )
continue;
LCD_data( temp++ );
delay(2000);
transmit();
for( count = 0; count < CMDLEN_GETFOLDERSTAT; count++ )
{
sendbyte( CMD_GETFOLDERSTAT[count] );
}
LCD_data( temp++ );
delay( 2000 );
receive();
for( ;; )
{
if( flag == 1 )
{
if( rcdata == 0x1e )
LCD_data( temp++ );
flag = 0;
}
}
}
void initUART()
{
SPBRG = 9;
RCIE = 1;
PEIE = 1;
GIE = 1;
}
void sendbyte( unsigned char tmp )
{
while( !TXIF )
continue;
TXREG = tmp;
}
void transmit()
{
TXSTA = 0x24;
RCSTA = 0x80;
}
void receive()
{
TXSTA = 0x04;
RCSTA = 0x90;
}
void interrupt serial_isr()
{
if(RCIF && RCIE)
{
rcdata = RCREG;
flag = 1;
}
}
void initLCD()
{
delay(2000);
LCD_inst(0x38);
LCD_inst(0x06);
LCD_inst(0x0F);
LCD_inst(0x01);
}
void LCD_inst(unsigned char x)
{ delay(1000);
PORTB = x;
RA0 = 0;
RA1 = 0;
delay(1500);
RA1 = 1;
}
void LCD_data(unsigned char data)
{ delay(2000);
PORTB =data;
RA0 = 1;
RA1 = 0;
delay(2000);
RA1 = 1;
}
void delay(int x)
{
while(x--);
}