Hi,
I have a project using LCD 4x20, I did some advanced projects with C51 code and no problems before with LCD 1X16,2X16 and 4X16 .
This one should be done with PIC16F877A for availability problem at destination area.
I tried the examples with Great Cow compiler and Prithvi for LCD light meter and both worked fine,
The MiKroElektronica example gave me at compile error message with 2 lines
" ANSEL = 0 ' Configure AN pins as digital I/O
ANSELH = 0"
Saying ANSEL was not declared, commenting both lines, the code generated does not work
I reconfigured the breadboard to my schematic and that configuration worked fine with previous light meter, then I used the steps I used with C51 , but no result, I made a simple loop to write "M" then flash led then "3" then flash led and loop, the only result I get is the program runs till initialization of LCD and it shows 2 lines and the cursor at Line 1 Char 1 and even the LED does not flash.
On oscilloscope the oscillator is running, but all the port pins are not changing.
Attached please find the test project I used
Having difficulty running LCD code
-
- Posts: 27
- Joined: 26 Dec 2014 11:01
- Location: Cairo
- Contact:
Having difficulty running LCD code
- Attachments
-
- LCD tst.zip
- (24.31 KiB) Downloaded 111 times
Re: Having difficulty running LCD code
Hi,
ANSEL or ANSELH do not exist in the P16F877A.
You should use register ADCON1 in stead and fill it with value 6 to set all inputs to digital. See the pic's datasheet page 128.
ANSEL or ANSELH do not exist in the P16F877A.
You should use register ADCON1 in stead and fill it with value 6 to set all inputs to digital. See the pic's datasheet page 128.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
-
- Posts: 27
- Joined: 26 Dec 2014 11:01
- Location: Cairo
- Contact:
Re: Having difficulty running LCD code
Hi,
Thanks very much for this information, sorry I overlooked it because I mixed 16f877 with 887
Here I did what you suggested, still the LCD configures to 2 lines and the cursor stops at 1st character, the LED does not flash.
I reconfigured the circuit to use portc instead (attached) the only difference it the LED turns on and stays on
Thanks very much for this information, sorry I overlooked it because I mixed 16f877 with 887
Here I did what you suggested, still the LCD configures to 2 lines and the cursor stops at 1st character, the LED does not flash.
I reconfigured the circuit to use portc instead (attached) the only difference it the LED turns on and stays on
- Attachments
-
- LCD tst-m.zip
- (47.01 KiB) Downloaded 112 times
-
- Posts: 27
- Joined: 26 Dec 2014 11:01
- Location: Cairo
- Contact:
Re: Having difficulty running LCD code
if I exceed the stack limit, will the program issue an alarm?
Re: Having difficulty running LCD code
Code: Select all
dim i, ... as byte ' Loop variable and sensor faults
sub Procedure WaitMS(dim Time_mSec as word)
for i = 1 to Time_mSec
Wait1ms
next i
end sub
while true
TstLED = 1
WaitMS (500)
p.s. If you had defined "I" locally in the WaitMS procedure the problem could have been spotted more easily... (and the code would have been more robust also)
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
-
- Posts: 27
- Joined: 26 Dec 2014 11:01
- Location: Cairo
- Contact:
Re: Having difficulty running LCD code
1st I am sorry for late reply as I was busy doing something else.
2nd Thanks very much that was it, it solved my problem.
Thanks again
2nd Thanks very much that was it, it solved my problem.
Thanks again