CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Delay not working

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
space2000



Joined: 10 Jun 2011
Posts: 5

View user's profile Send private message

Delay not working
PostPosted: Fri Jun 10, 2011 8:34 pm     Reply with quote

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: 19431

View user's profile Send private message

PostPosted: Sat Jun 11, 2011 2:29 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Jun 11, 2011 4:57 am     Reply with quote

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: 9196
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Jun 11, 2011 5:42 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Jun 11, 2011 6:43 am     Reply with quote

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: 9196
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Jun 11, 2011 7:30 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Jun 11, 2011 5:41 pm     Reply with quote

I send you pm. thanks.
space2000



Joined: 10 Jun 2011
Posts: 5

View user's profile Send private message

PostPosted: Mon Jun 13, 2011 12:00 am     Reply with quote

Hi,

Delay Problem is solved. i found that i used #fuse in two Places so the delay was not working. now its ok.

thanks.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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