View previous topic :: View next topic |
Author |
Message |
space2000
Joined: 10 Jun 2011 Posts: 5
|
Delay not working |
Posted: Fri Jun 10, 2011 8:34 pm |
|
|
hi,
I am new here. I am having delay problem with 16F876. My device is using a LCD 16X2 and some Led out put at RC0 for blink.
Here is the program. Delay inside Lcd is working but other sub Delays are not working. if i don't use LCD.c then the delay is working fine.
Thanks.
#include <16f876.h>
#include <stdlib.h>
#include <lcd.c>
#include <string.h>
#fuses XT,NoWDT,NOPUT,NOPROTECT,NOBROWNOUT,NOLVP
#use delay(clock=4000000) //4mhz
lcdtext()
{
lcd_init();
delay_ms(5); // <----- delays
lcd_putc("\f"); //Clear display
delay_ms(5);
lcd_gotoxy(3,1); //lcd location x,y
delay_ms(5);
lcd_putc("EQ MOUNT"); // you want to send this to the lcd only once
lcd_gotoxy(1,2); //lcd location x. y
delay_ms(5);
lcd_putc("Vixen GP2"); // you want to send this to the lcd only once
}
ledblink() ///Problem is in this sub delay.
{
cp:
output_low(RC1);
output_high(RC0);
delay_ms(500); // delay not working
output_low(RC0);
output_high(RC1);
delay_ms(500); // delay not working
goto cp;
}
void main()
{
int kl,i;
char my[10];
set_tris_a(0B111111); //as input
set_tris_b(0B00000000); //as ouput /this for lcd
set_tris_c(0B00000000); //as output , blink the led
// output_B(0X0); //all low
output_C(0X0); //all low
lcdtext();
//delay_ms(1000); / / delay not working
ledblink();
} |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Sat Jun 11, 2011 2:29 am |
|
|
What hardware have you got to drive the LED's?. Sort of thing that could cause problems, too much current being drawn from the pins of the PIC, resulting in it hanging/resetting, so you don't think delays are working. Without the LCD, less current consumption, and faster reset, so behaviour is different.
Get rid of your TRIS settings. These are doing nothing (the compiler handles TRIS for you), and are wrong (the LCD needs to read the status as well as write data....).
Best Wishes |
|
|
space2000
Joined: 10 Jun 2011 Posts: 5
|
|
Posted: Sat Jun 11, 2011 4:57 am |
|
|
Thanks for advice. I just added 220ohms resister in between LED and Pic pin RC0. I removed all TRIS and still same problem. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9241 Location: Greensville,Ontario
|
|
Posted: Sat Jun 11, 2011 5:42 am |
|
|
hmm...
output_low(RC1);
where do YOU define RC1 as being an I/O pin on your PIC ?
CCS defines it in their header as PIN_C1.
Same holds true for C1.
I suspect you've copied this code from Picbasic ? and the syntax is NOT the same.
Pressing F11 while the project is open, will open the CCS Help file, full of helpful information. It's a great easy to use onscreen reference !! |
|
|
space2000
Joined: 10 Jun 2011 Posts: 5
|
|
Posted: Sat Jun 11, 2011 6:43 am |
|
|
I just checked that LCD.C is the problem maker. When I include this file the led blinking do not work. LCD still wroking.
My compiler is PCW version 3.10 PICC. I downloaded for free. It worked well for me.
++++++++++++++++++++++++++
Code deleted.
Reason: CCS Forum Policy and Guidelines
9. No pirating
http://www.ccsinfo.com/forum/viewtopic.php?t=26245
- Forum Moderator
++++++++++++++++++++++++++
Even thou now I changed the RC0 to PIN_C0 on Header file still same problem.
Header File:
//////// Standard Header file for the PIC16F876 device ////////
*** Deleted ***
MY LCD.C FILE.
////////////////////////////////////////////////////////////////////////////
//// LCD.C ////
*** Deleted *** |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9241 Location: Greensville,Ontario
|
|
Posted: Sat Jun 11, 2011 7:30 am |
|
|
So you're saying that you have a simple 'blinking LED program working ?
A program without the LCD header and ANY code LCD related using RC0 ?
Please show us the code. |
|
|
space2000
Joined: 10 Jun 2011 Posts: 5
|
|
Posted: Sat Jun 11, 2011 5:41 pm |
|
|
I send you pm. thanks. |
|
|
space2000
Joined: 10 Jun 2011 Posts: 5
|
|
Posted: Mon Jun 13, 2011 12:00 am |
|
|
Hi,
Delay Problem is solved. i found that i used #fuse in two Places so the delay was not working. now its ok.
thanks. |
|
|
|