View previous topic :: View next topic |
Author |
Message |
Ken Guest
|
MCLR strange problem |
Posted: Thu Jan 05, 2006 1:37 am |
|
|
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
|
|
Posted: Thu Jan 05, 2006 2:08 am |
|
|
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
|
|
Posted: Thu Jan 05, 2006 2:15 am |
|
|
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? |
|
|
Guest
|
|
Posted: Thu Jan 05, 2006 6:25 am |
|
|
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
|
|
Posted: Thu Jan 05, 2006 6:26 am |
|
|
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
|
|
Posted: Thu Jan 05, 2006 7:37 am |
|
|
Whoops....sorry I got it. It should be NOMCLR fuse. |
|
|
|