- This topic has 4 replies, 4 voices, and was last updated 12 years, 9 months ago by
midhun.
Viewing 5 posts - 1 through 5 (of 5 total)
-
AuthorPosts
-
May 30, 2012 at 1:00 pm #1824
osama
ParticipantHi every one
i wrote this code for a project to interface EM-406A with PIC 16F877
but it does’t work .
char uart_rd;char uart[11];// LCD module connectionssbit LCD_RS at LATB2_bit;sbit LCD_EN at LATB3_bit;sbit LCD_D4 at LATB4_bit;sbit LCD_D5 at LATB5_bit;sbit LCD_D6 at LATB6_bit;sbit LCD_D7 at LATB7_bit;sbit LCD_RS_Direction at TRISB2_bit;sbit LCD_EN_Direction at TRISB3_bit;sbit LCD_D4_Direction at TRISB4_bit;sbit LCD_D5_Direction at TRISB5_bit;sbit LCD_D6_Direction at TRISB6_bit;sbit LCD_D7_Direction at TRISB7_bit;// End LCD module connectionsvoid main() {TRISB = 0;PORTB = 0x00;UART1_Init(4800); // Initialize UART module at 9600 bpsDelay_ms(3000); // Wait for UART module to stabilize//UART1_Write_Text(“Start”);Lcd_Init(); // Initialize LCDLcd_Cmd(_LCD_CLEAR); // Clear displayLcd_Cmd(_LCD_CURSOR_OFF); // Cursor offlcd_out(1,1,”lcd”);delay_ms(1000);uart1_write(0x08);delay_ms(5000);while(1) {// uart1_write_text(“$GPGGA,002153.000,3342.6618,N,11751.3858,W,1,10,1.2,27.0,M,-34.2,M,,0000*5E,0x0d,0x0a”);//uart1_write_text(“$GPGLL,3723.2475,N,12158.3416,W,161229.487,A,A*41,0x0d,0x0a”);//uart1_write(0x0d);//uart1_write(0x0a);delay_ms(2000);delay_ms(10000);if(UART1_Data_Ready()) { // If data is received,uart_rd=uart1_read();// gps_value=gps_data(GPS_LATHIGH);lcd_chr(2,12,uart_rd);uart1_read_text(uart, “.”, 15);lcd_out(1,5, uart);delay_ms(500);}}}any suggestionsthank u.May 30, 2012 at 4:57 pm #7940AJISH ALFRED
ParticipantHi,
Have you initialized the uart1 properly for the baud rate of 9600?
Don’t try writing into the uart, all you have to do is to read the data coming into the uart1 from the gps.
Could you please comment your code properly and update, so that it would be easy for some one who can really help you with it.
May 31, 2012 at 9:53 am #7943osama
Participantchar uart_rd;char uart[11];// LCD module connectionssbit LCD_RS at LATB2_bit;sbit LCD_EN at LATB3_bit;sbit LCD_D4 at LATB4_bit;sbit LCD_D5 at LATB5_bit;sbit LCD_D6 at LATB6_bit;sbit LCD_D7 at LATB7_bit;sbit LCD_RS_Direction at TRISB2_bit;sbit LCD_EN_Direction at TRISB3_bit;sbit LCD_D4_Direction at TRISB4_bit;sbit LCD_D5_Direction at TRISB5_bit;sbit LCD_D6_Direction at TRISB6_bit;sbit LCD_D7_Direction at TRISB7_bit;// End LCD module connectionsvoid main() {TRISB = 0;PORTB = 0x00;UART1_Init(4800); // Initialize UART module at 9600 bpsDelay_ms(3000); // Wait for UART module to stabilize//UART1_Write_Text(“Start”);Lcd_Init(); // Initialize LCDLcd_Cmd(_LCD_CLEAR); // Clear displayLcd_Cmd(_LCD_CURSOR_OFF); // Cursor offlcd_out(1,1,”lcd”);delay_ms(1000);uart1_write(0x08);delay_ms(5000);while(1) {delay_ms(2000);delay_ms(10000);if(UART1_Data_Ready()) { // If data is received,uart_rd=uart1_read();// gps_value=gps_data(GPS_LATHIGH);lcd_chr(2,12,uart_rd);uart1_read_text(uart, “.”, 15);lcd_out(1,5, uart);delay_ms(500);}}}June 5, 2012 at 9:47 am #7970Anonymous
Guesti have the same prob , i send a msg when i find the solution.
June 19, 2012 at 12:57 pm #8078midhun
Participantchar uart_rd;char uart[11];// LCD module connectionssbit LCD_RS at LATB2_bit;sbit LCD_EN at LATB3_bit;sbit LCD_D4 at LATB4_bit;sbit LCD_D5 at LATB5_bit;sbit LCD_D6 at LATB6_bit;sbit LCD_D7 at LATB7_bit;sbit LCD_RS_Direction at TRISB2_bit;sbit LCD_EN_Direction at TRISB3_bit;sbit LCD_D4_Direction at TRISB4_bit;sbit LCD_D5_Direction at TRISB5_bit;sbit LCD_D6_Direction at TRISB6_bit;sbit LCD_D7_Direction at TRISB7_bit;// End LCD module connectionsvoid main() {TRISB = 0;PORTB = 0x00;UART1_Init(4800); // Initialize UART module at 9600 bps*******************************************UART1_Init(9600);Delay_ms(3000); // Wait for UART module to stabilize//UART1_Write_Text(“Start”);// not required, you only receive data. dont send any.Lcd_Init(); // Initialize LCDLcd_Cmd(_LCD_CLEAR); // Clear displayLcd_Cmd(_LCD_CURSOR_OFF); // Cursor offlcd_out(1,1,”lcd”); why to display “LCD”?delay_ms(1000);uart1_write(0x08);// why writing this???? remove it.delay_ms(5000);// not required.while(1) {delay_ms(2000);delay_ms(10000);/// together you can write it asdelay_ms(12000);if(UART1_Data_Ready()) { // If data is received,uart_rd=uart1_read();// gps_value=gps_data(GPS_LATHIGH);lcd_chr(2,12,uart_rd);uart1_read_text(uart, “.”, 15);lcd_out(1,5, uart);delay_ms(500);}}}just try it nw….BEST OF LUCK. -
AuthorPosts
Viewing 5 posts - 1 through 5 (of 5 total)
- You must be logged in to reply to this topic.