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

Pic16F690 problem

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



Joined: 07 Jul 2008
Posts: 2

View user's profile Send private message

Pic16F690 problem
PostPosted: Mon Jul 07, 2008 4:43 am     Reply with quote

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);
   }
 }
}
Ttelmah
Guest







PostPosted: Mon Jul 07, 2008 7:12 am     Reply with quote

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
freddan007



Joined: 07 Jul 2008
Posts: 2

View user's profile Send private message

PostPosted: Mon Jul 07, 2008 8:41 am     Reply with quote

All the asm examples work correctly
Ttelmah
Guest







PostPosted: Mon Jul 07, 2008 10:17 am     Reply with quote

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
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jul 07, 2008 10:33 am     Reply with quote

Look at page 41 in the PicKit2 "low pin count" user manual:
http://ww1.microchip.com/downloads/en/DeviceDoc/Low%20Pin%20Count%20User%20Guide%2051556a.pdf
Probably it will work if jumper JP5 is installed and you add the NOMCLR
fuse.
Guest








PostPosted: Mon Jul 07, 2008 11:23 am     Reply with quote

how do i install the jp5 jumper?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jul 07, 2008 11:44 am     Reply with quote

This board is a Microchip product and you should ask questions about
it on their forum. They have a FAQ on the PicKit2 board. FAQ
question "F" is about the pushbutton pin:
http://forum.microchip.com/tm.aspx?m=270347

Here is the Microchip forum for questions on how to use the PicKit2
"low pin count" board:
http://forum.microchip.com/tt.aspx?forumid=15
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