|
|
View previous topic :: View next topic |
Author |
Message |
GOBER Guest
|
|
Posted: Fri Jan 08, 2010 4:30 am |
|
|
Ok here's my test program:
Code: |
#include <16F688.h>
#use delay(clock=8000000)
#include "C:\Users\Alaa\Desktop\Flex LCD162 Test 16F688\FLEXLCD162.C"
#fuses NOWDT,INTRC_IO,NOCPD,NOPROTECT,PUT,MCLR, NOBROWNOUT,NOIESO,NOFCMEN
void main()
{
setup_oscillator(OSC_8MHZ);
setup_comparator(NC_NC_NC_NC);
lcd_init();
lcd_putc( "HELLO WORLD ");
}
|
PS: it told me that there is no defined function as delay_us() until I moved the #use delay(clock=8000000) to under the include"16f688.h" directly. WHY?!
Anyway, neither way works fine. I can see nothing on the lcd.
The pin map in the flex lcd driver is as follows:
Code: |
d4->c2
d5->c3
d6->c4
d7->c5
e->c1
rs->c0
|
Nothing is showing on the lcd! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jan 08, 2010 1:26 pm |
|
|
Have you ever made this PIC do anything, such as blinking an LED ?
If not, try following program. Use this exact program. Connect the
anode of an LED to the PIC with a 470 ohm series resistor. Connect
the cathode of the LED to ground. Here's a schematic:
Code: |
16F688
------
| 470 ohm LED
RC3|-----/\/\/\/------->|-----|
| |
| ---
| GND
------
|
Here's the test program. It should blink the LED on pin C3.
I tested this in hardware with vs. 4.104 and it worked.
Code: |
#include <16F688.h>
#fuses INTRC_IO, NOWDT, PUT, BROWNOUT, NOMCLR
#use delay(clock=8000000)
//====================================
void main()
{
while(1)
{
output_high(pin_C3);
delay_ms(500);
output_low(pin_C3);
delay_ms(500);
}
}
|
|
|
|
GOBER Guest
|
|
Posted: Sat Jan 09, 2010 2:42 am |
|
|
Hey PCM Programmer
Thanks for reply.
I tried what you wrote to me and it works fine.
However I tried out this thing:
16f684 is somehow like 16f688 in pins except that 16f688 has euart while 16f688 don't on pins c4 and c5. So I started my program as a program for pic16f688 but then I changed the include"16f688" to include "16f684" and recompiled my program. I got no errors and I tried the program on proteus using both pics 16f684 and 16f688 with the same program(include"16f684") and it worked fine with the lcd. So I guess something is going wrong with the uart initialization in the 16f688 and I tried to figure it out but I couldn't.
can you pls try to find out |
|
|
Ttelmah Guest
|
|
Posted: Sat Jan 09, 2010 3:45 am |
|
|
On the 'why' for the clock statement position, this comes down to the compiler not knowing the details of your chip, till the processor defines are included. When you put the clock statement in the code, it generates the basic code for delays. The processor statement, really must be before anything else.
On the UART, try:
#byte RXSTA=0x17
#bit SPEN=RXSTA.7
Then in your main just set:
SPEN=0;
This ensures the UART is turned off.
Best Wishes |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jan 10, 2010 2:32 pm |
|
|
I used a 16F688 board and a PicDem2-Plus board to test your problem.
I jumpered the 16F688 pins used for the LCD over to the LCD pins on the
PicDem2-Plus board. I removed the PIC from the PicDem2-Plus board,
so the 16F688 could control the LCD. I compiled your test program with
vs. 4.104. It worked.
Therefore, you probably have a hardware problem, such as crossed
wires, or a solder short, or lacking a MCLR pull-up resistor, or incorrect
contrast voltage on the LCD, or incorrect power and ground connections
on the LCD, etc.
But you may also have a Flex_ lcd.c driver configuration problem.
In my test program, the flex_lcd.c file has these define statements, and
the R/W #define is commented out:
Code: |
#define LCD_DB4 PIN_C2
#define LCD_DB5 PIN_C3
#define LCD_DB6 PIN_C4
#define LCD_DB7 PIN_C5
#define LCD_E PIN_C1
#define LCD_RS PIN_C0
// The line below is commented out,
// so a 6-pin LCD interface can be used:
//#define USE_RW_PIN 1
|
The LCD R/W pin is jumpered to ground on the PicDem2-Plus board.
There is a ground connection between the 16F688 board and the PicDem2
Plus board.
The LCD contrast pin has 0.28 volts on it, measured with a voltmeter.
This voltage is set with two resistors which make a voltage divider on
the PicDem2-Plus board. Any LCD contrast voltage in the range of
0 to 0.5 volts should allow you to see something on the LCD.
In the code below, note that the NOMCLR fuse is used. This means that
a pull-up resistor is not required on the 16F688's MCLR pin.
Both boards are running at +5 volts.
Code: |
#include <16F688.h>
#fuses INTRC_IO, NOWDT, PUT, BROWNOUT, NOMCLR
#use delay(clock=8000000)
#include "flex_lcd.c"
//====================================
void main()
{
lcd_init();
lcd_putc("Hello World");
while(1);
} |
|
|
|
GOBER Guest
|
|
Posted: Mon Jan 11, 2010 3:52 am |
|
|
Dear all who ever interfered and tried to help, especially PCM programmer
after two weeks of trying hard, it turned out that there were no bug in my test program and that it was totally correct. the bug is that i was always trying to test the program using proteus, and it never worked. but when i tried it on my board, i worked.
so the problem was PROTEUS. it has some bug in the pic16f688. i tried you test program pcm programmer and mine too, both on the proteus and on the board. they both failed with proteus but worked excellently on the board.
i'm very sorry for your time wasted on trying to help me, and i'm very thankful to all of you.
pls forgive me and take care all |
|
|
|
|
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
|