rjwilliams
Newbie level 2
- Joined
- Mar 25, 2015
- Messages
- 2
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 3
- Activity points
- 26
I am using a pic16f877a, an EM-506 GPS module, and a 16x2 LCD to display the Speed Over Ground and using Timer 0 as the timer and Timer 1 as a counter to display RPM's. I can get the RPM's and speed to display individually but not at the same time. For the tachometer, I set the pre-scalar to 0x07 to create the longest delay possible prior to servicing the interrupt which increments a counter until the timer = 1 second at which point I multiply the value by 60 to create RPM's. I think the constant interrupting from Timer 0 effects the baud rate and prevents the GPS routine from running properly. Is there anyway to fix this? Also, by multiplying the value by 60 each time I get increments of 60 in the tachometer value, any work around to this? Thank you very much.
The LED is activated by port b change. When a button is pressed, the LED turns on indicating which routine is being run. This is the only way I can display it. The GPS_GetData andDisplayIt polls the RCIF flag and then begins to parse the nmea data string.
The LED is activated by port b change. When a button is pressed, the LED turns on indicating which routine is being run. This is the only way I can display it. The GPS_GetData andDisplayIt polls the RCIF flag and then begins to parse the nmea data string.
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 /****** Main Program Loop***************************************************/ while(1) { while(LED2==0) { T1CONbits.TMR1ON = 0; // Enable counter INTCONbits.T0IE = 0; // Timer 0 Interrupt Enabled (Timer) GPS_GetDataAndDisplayIt(); // Execute GPS Protocol WriteCmd_LCD(0x0C); } if(LED2==1) { T1CONbits.TMR1ON = 1; // Enable counter INTCONbits.T0IE = 0; // Timer 0 Interrupt Enabled (Timer) __delay_ms(1000); INTCONbits.T0IE = 0; // Timer 0 Interrupt Disabled (Timer) T1CONbits.TMR1ON = 0; // Stop counter rbcounter = TMR1L*60; // Pulse counter mins to secs TMR1L = 0x00; // Reset TMR1 utoa(result,rbcounter,10); // Convert rbcounter into string WriteCmd_LCD(0x02); // LCD home position ClearScreen_LCD(); // Clear LCD MoveCursorToPosition(SecondLine); // Second row WriteString_LCD("Tach: "); // Display label WriteString_LCD(result); // Display value WriteString_LCD(" RPM"); // Display units WriteCmd_LCD(0x0C); rbcounter = 0; // Reset counter LED1 = 0; // LED off T1CONbits.TMR1ON = 1; // Start counter INTCONbits.T0IE = 1; // Timer 0 Interrupt Enabled (Timer) } } } return 0; }
Last edited by a moderator: