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 CCS Technical Support

MCLR strange problem

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







MCLR strange problem
PostPosted: Thu Jan 05, 2006 1:37 am     Reply with quote

Hi all,

Here is my code to set MCLR/RA5 pin as input to blink LED as stated....problem is when input is high LED blink @ 200ms, just the opposite and when input is low it won't blink at all, output goes low forever!! Whats the trouble...here.

Thanks

Code:

#include <16F628.h>
#fuses xt,nowdt,noprotect,nolvp,mclrtimer
#use delay(clock=4000000)// 4Mhz crystal frequency
void main()
{
while(true)
   {
      if(input(PIN_A5)==1)
      {
      output_high(PIN_B3);
      delay_ms(500);   
      output_low(PIN_B3);
      delay_ms(500);   
      }
      else if(input(PIN_A5)==0)
      {
      output_high(PIN_B3);
      delay_ms(200); 
      output_low(PIN_B3);
      delay_ms(200); 
      }
   }
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jan 05, 2006 2:08 am     Reply with quote

Look at the list of valid fuse settings in the 16F628.H file.
Compare it to your fuses and see if you notice something.
Storic



Joined: 03 Dec 2005
Posts: 182
Location: Australia SA

View user's profile Send private message Send e-mail

PostPosted: Thu Jan 05, 2006 2:15 am     Reply with quote

Hi,

Have you tried doing the else without the "if(input(PIN_A5)==0)" you are using PIN_A5 as a digital input and the condition will be one or the other.

Andrew
_________________
What has been learnt if you make the same mistake? Wink
Guest








PostPosted: Thu Jan 05, 2006 6:25 am     Reply with quote

PCM programmer wrote:
Look at the list of valid fuse settings in the 16F628.H file.
Compare it to your fuses and see if you notice something.


Hi CM programmer,

Oh....sorry *mclrtimer* was just typos, its actually mclr!! Any more comment....I still can't make it work.

Thanks
Guest








PostPosted: Thu Jan 05, 2006 6:26 am     Reply with quote

PCM programmer wrote:
Look at the list of valid fuse settings in the 16F628.H file.
Compare it to your fuses and see if you notice something.


Hi CM programmer,

Oh....sorry *mclrtimer* was just typos, its actually mclr!! Any more comment....I still can't make it work.

Thanks
Ken
Guest







PostPosted: Thu Jan 05, 2006 7:37 am     Reply with quote

Whoops....sorry I got it. It should be NOMCLR fuse.
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