![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
bimba
Joined: 12 Jan 2013 Posts: 12
|
ZERO Output on the LCD |
Posted: Mon Feb 25, 2013 8:29 am |
|
|
Dear All,
After successful compilation of this code in ccs, the LCD output Zero. Please
help out.
Thanks
[#include <16F877A.h>
#device *= 16
#device adc=8
#fuses HS, NOWDT, NOPROTECT, NOLVP, PUT
#fuses NOBROWNOUT, CPD, NODEBUG, NOWRT
#use delay(clock=10MHz)
#use rs232(baud=1200, xmit=PIN_C6, bits=8, parity=N)
#include <lcd.c>
void main()
{
byte s=0;
lcd_init();
lcd_putc("\f");
setup_adc_ports(adc_clock_internal);
setup_adc(AN0);
set_adc_channel(0);
while(true)
{
read_adc(adc_start_only);
while(!adc_done());
s = read_adc(adc_read_only);
lcd_gotoxy(1,1);
printf(lcd_putc, "\fTx Data = %u" s);
putc(s);
delay_ms(100);
}
}
http://img96.imageshack.us/img96/4327/similarprj.png |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9178 Location: Greensville,Ontario
|
|
Posted: Mon Feb 25, 2013 9:19 am |
|
|
Time to debug..
Take smaller steps....
Get rid of the ADC code as well as the serial to the PC.
Only have 'LCD' related code.
'LCD output ZERO' isn't very helpful.
Do you get a single row of blacks squares or a totally 'dead' LCD, with NOTHING showing?
What LCD module?
What is Vee(contrast) value?
What is your compiler version?
Is it a premade protoboard,wirewrap,breadboard,???
we need more information to help you.
Also, can you get a 'blinking LED' program to run ?
hth
jay |
|
![](templates/subSilver/images/spacer.gif) |
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Mon Feb 25, 2013 10:11 am |
|
|
Hi,
Have you searched the forum for help with this issue? There are tons of threads here about LCD interfacing, and troubleshooting. Here is a recent one: http://www.ccsinfo.com/forum/viewtopic.php?t=49903&highlight=lcd
At a minimum, you need to add a delay before the lcd_init() call to allow your LCD module enough time to complete its power up sequence.
Also, learn to use the 'Code' button when adding code to your posts, it makes everything much more readable.....
John |
|
![](templates/subSilver/images/spacer.gif) |
bimba
Joined: 12 Jan 2013 Posts: 12
|
|
Posted: Mon Feb 25, 2013 3:47 pm |
|
|
thanks jay,
what i mean by 'LCD output ZERO' is that i was expecting something like
Rx =90 as written in my code, but instead i got Rx = 0 on the LCD.
I am using ccs c v 4.104 and i simulated on proteus 7 and the LCD is
LM020L. i think there's something am not doing right in the code.
Regards
temtronic wrote: | Time to debug..
Take smaller steps....
Get rid of the ADC code as well as the serial to the PC.
Only have 'LCD' related code.
'LCD output ZERO' isn't very helpful.
Do you get a single row of blacks squares or a totally 'dead' LCD, with NOTHING showing?
What LCD module?
What is Vee(contrast) value?
What is your compiler version?
Is it a premade protoboard,wirewrap,breadboard,???
we need more information to help you.
Also, can you get a 'blinking LED' program to run ?
hth
jay |
|
|
![](templates/subSilver/images/spacer.gif) |
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Mon Feb 25, 2013 4:58 pm |
|
|
bimba wrote: | I am using ccs c v 4.104 and i simulated on proteus 7 and the LCD is
LM020L. |
How do you KNOW the value of s in this code fragment?
Code: |
printf(lcd_putc, "\fTx Data = %u" s);
|
Is there not a comma missing?
Best advice I can give is, forget Proteus.
Work with REAL hardware.
If (when) you're stuck ask for help.
Mike |
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Feb 25, 2013 5:16 pm |
|
|
I don't see why your ADC is always reading 0, perhaps a wrong schematic in Proteus?
There are a few other problems though that show you are not giving enough attention to details.
Code: | printf(lcd_putc, "\fTx Data = %u" s); | I'm surprised this compiles as the syntax is wrong, a ',' is missing. Code: | printf(lcd_putc, "\fTx Data = %u", s); | It doesn't change anything in the resulting assembly code, but an error none the less.
Code: | setup_adc_ports(adc_clock_internal);
setup_adc(AN0); | should be: Code: | setup_adc(adc_clock_internal);
setup_adc_ports(AN0); | Though, for the PIC16F877A, the resulting code is equivalent.
Code: | #use rs232(baud=1200, xmit=PIN_C6, bits=8, parity=N) | This will create a software simulated UART. It will work but doesn't make sense when you use the pin for the hardware UART. Change to: Code: | #use rs232(baud=1200, xmit=PIN_C6, rcv=PIN_C7, bits=8, parity=N) | or even better: Code: | #use rs232(baud=1200, xmit=PIN_C6, rcv=PIN_C7, bits=8, parity=N, errors) |
|
|
![](templates/subSilver/images/spacer.gif) |
bimba
Joined: 12 Jan 2013 Posts: 12
|
|
Posted: Fri Mar 01, 2013 5:25 am |
|
|
Thanks all,
i have been able to correct the errors.
but another issue is this, after adding some more components on proteus,
and simulating, i get this error :
[PIC16 ADC] PC =0X021F. ADC Conversion clock period(4e-08) is less than min TAd=1.6us and is possibly invalid for device clock frequency.
please how do i overcome this too?,,i have been reading the PIC manual..but no way out.
thanks
Regards,
ckielstra wrote: | I don't see why your ADC is always reading 0, perhaps a wrong schematic in Proteus?
There are a few other problems though that show you are not giving enough attention to details.
Code: | printf(lcd_putc, "\fTx Data = %u" s); | I'm surprised this compiles as the syntax is wrong, a ',' is missing. Code: | printf(lcd_putc, "\fTx Data = %u", s); | It doesn't change anything in the resulting assembly code, but an error none the less.
Code: | setup_adc_ports(adc_clock_internal);
setup_adc(AN0); | should be: Code: | setup_adc(adc_clock_internal);
setup_adc_ports(AN0); | Though, for the PIC16F877A, the resulting code is equivalent.
Code: | #use rs232(baud=1200, xmit=PIN_C6, bits=8, parity=N) | This will create a software simulated UART. It will work but doesn't make sense when you use the pin for the hardware UART. Change to: Code: | #use rs232(baud=1200, xmit=PIN_C6, rcv=PIN_C7, bits=8, parity=N) | or even better: Code: | #use rs232(baud=1200, xmit=PIN_C6, rcv=PIN_C7, bits=8, parity=N, errors) |
|
|
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9178 Location: Greensville,Ontario
|
|
Posted: Fri Mar 01, 2013 6:35 am |
|
|
Honestly WHY do you THINK Proteus is working 100%?
CCS kindly supplies working example code for the 877 using all the internal peripherals.
It is very well known that Proteus has hundreds of 'issues', faulty DRC, etc. so do NOT believe what happens (good or bad) in the 'simulation.
I've yet to see ONE Proteus schematic that will actuallly work as presented! Start with a bad schematic, run a bad simulator and no good will ever come of it.
I strongly suggest you remove proteus from your PC and use real working code on real hardware. For less than $50 you can buy a LOT of PIC and parts, giving you real hands on experience. |
|
![](templates/subSilver/images/spacer.gif) |
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Fri Mar 01, 2013 6:41 am |
|
|
I repeat, THROW AWAY PROTEUS.
To best get help:-
1) Reduce your code to the minimum which illustrates the problem.
2) Post your complete and compilable code.
3) Tell us you version number.
4) Use the "code" button.
5) Get rid of all mention of Proteus
Mike |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19383
|
|
Posted: Fri Mar 01, 2013 8:55 am |
|
|
However, do a search here (dozens of threads), and look at the data sheet. What does it say in relation to the internal RC ADC clock, and device operating frequencies about 1MHz?.
Annoyingly this is one that CCS also get wrong in several of their examples....
Best Wishes |
|
![](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
|