View previous topic :: View next topic |
Author |
Message |
freddan007
Joined: 07 Jul 2008 Posts: 2
|
Pic16F690 problem |
Posted: Mon Jul 07, 2008 4:43 am |
|
|
Hello!
I have a pickit2 starterkit and a ccs c compiler.
And it works great but I am having trouble with the input.
I use this code but when I press the button on my experimentcard nothing happens.
Code: | #include <16F690.H>
#fuses INTRC_IO, NOWDT, NOPROTECT, BROWNOUT , PUT
#use delay(clock=4000000)
//====================================
void main()
{
while(1)
{
if((input(PIN_A3)))
{
output_high(PIN_C0);
}
}
} |
|
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Mon Jul 07, 2008 7:12 am |
|
|
How have you wired the button?.
Normally, you will need a button pulling the signal either down to ground, or up to 5v, and a _resistor_ pulling the same line the 'other way' (so button 'down' to 0v, and resistor 'up' to 5v, or the whole combination 'reversed'). Now the 690, has 'programmable' pull up resistors on PORTA, but these have to be turned on by _you_. Look at the port_a_pullups instruction. Without the resistor, there is nothing to make the line go high...
Note also, that if you are using the internal pullups, and the button to ground, the logic you show is reversed. The signal will go 'true', when the button is _not_ pushed.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
freddan007
Joined: 07 Jul 2008 Posts: 2
|
|
Posted: Mon Jul 07, 2008 8:41 am |
|
|
All the asm examples work correctly |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Mon Jul 07, 2008 10:17 am |
|
|
In which case, they are doing something different. Accessing a different pin, or making different assumptions.
They are probably setting the pullup resistors, which is why I suggest this.
The problem is that we don't know how the board you have is wired (hence my first comment).
With the right wiring, what you have posted will (sort of) work. However it'll only work once (since as soon as the pin is seen high, the output will set, and never release), and it requires a pin that goes high for 'active', which is the opposite of most normal wiring.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Mon Jul 07, 2008 11:23 am |
|
|
how do i install the jp5 jumper? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
![](templates/subSilver/images/spacer.gif) |
|