![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
amjad_alahdal
Joined: 19 Feb 2013 Posts: 50
|
Problem with PIC16F628A And Serial LCD |
Posted: Tue Mar 25, 2014 10:59 am |
|
|
Hi everyone,
I am using a PIC16F628A, and a sparkfun serial LCD,,
Well, I have a problem in displaying. Sometimes, the LCD works well, others it prints some strange characters such as Omega Symbol or Pi Symbol.
I am not using a Crystal for this PIC because, it works well without it.
Do I have to connect a crystal ?
If no, then I am in the right path.
If Yes, I need to tell you that I have already connected an 8MHz Crystal. Activated the HS in the FUSES, and didn't work.
In the following program, I am using an interrupt which I tested already, it worked well, but still having a displaying problem. Sometimes the LCD froze.
Code: |
#include<16F628A.h>
#DEVICE PASS_STRINGS = IN_RAM
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC //Internal RC Osc
#FUSES PUT //Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#USE DELAY(CLOCK = 4M)
#use rs232(baud=9600,xmit=PIN_B4,stream= COM_LCD)
#include<lcd.h>
static unsigned int16 counter ;
// inerrupt subroutine function.
#int_EXT
void Encoder_isr() {
counter++;
}
void main()
{
delay_ms(2000);
lcd_clear();
fprintf(COM_LCD,"Hello");
enable_interrupts(INT_EXT); //Activate the inerttupt
ext_int_edge( L_TO_H ); //the counter will count when the click goes from Low to High
clear_interrupt(INT_EXT); //Clearing the interrupt for better counting
enable_interrupts(GLOBAL); //Activate the Global interrupt of the PIC
while (TRUE)
{
lcd_cursor_move(2,1);
fprintf(COM_LCD,"%ld",counter);
}
}
|
this is the LCD
https://www.sparkfun.com/products/9396
why do I not use the regular LCD?
1- The pins are few
2- They don't sell it in my city.
Thanks |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Mar 25, 2014 11:56 am |
|
|
Quote: | #use rs232(baud=9600,xmit=PIN_B4,stream= COM_LCD)
#int_EXT
void Encoder_isr() {
counter++;
} |
You are using a software UART and you are interrupting the character
transmission and destroying the UART bit timing. That's the reason.
There are two possible solutions. The easiest and best one is to use
the hardware UART. Just specify UART1 as the parameter and don't
specify any pins. The compiler will automatically use the hardware
UART and it will use the two hardware UART pins, TX and RX.
The 2nd solution is to add the DISABLE_INTS parameter to the existing
#use rs232() line above. This will disable interrupts while the software
UART is transmitting the bits for each character. But, your #int_EXT
routine will be blocked for a maximum of one character time, if the
software UART is transmitting when the #int_ext interrupt occurs. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|