|
|
View previous topic :: View next topic |
Author |
Message |
uni_student
Joined: 01 Aug 2007 Posts: 38 Location: AUckland, NEW ZEALAND
|
port_b_pullups |
Posted: Sun Feb 15, 2009 4:04 am |
|
|
Hi, I only require pinB0 and pinB4 of port b to be pulled up and prefer the others not to be. My code does not seem to work as B0, B2, B3, B4, B6 and B7 are all pulled up. Below is my code. Help please!!
Code: | #include <18f1220.h>
#include <string.h>
#fuses HS, NOWDT, BROWNOUT, NOLVP
#use delay( clock=4000000)
#use rs232 (baud=9600, xmit=PIN_B1, parity=N, bits=8, INVERT, ERRORS, FORCE_SW)
#define coin1 PIN_B4
#define coin2 PIN_B0
#define LED PIN_B5
//int count;
void main(){
output_high (LED);
port_b_pullups(0b00010001);
//output_float(coin1);
//output_float(coin2);
delay_ms(5000);
output_low (LED);
while(TRUE){
if(input (coin1) == FALSE){
putc('a');
delay_ms(30);
}
if (input (coin2) == FALSE){
putc('b');
delay_ms(30);
}
}
}
|
|
|
|
drdelphi
Joined: 22 Apr 2007 Posts: 22 Location: Romania
|
|
Posted: Sun Feb 15, 2009 4:27 am |
|
|
I am not sure that your PIC supports individual pin pull-up. Most of the PICs do not. So port_b_pullups() will only accept true or false as parameter - all pins pulled up or none.
Did you consider pulling up the pins you need with external resistors ? |
|
|
Ttelmah Guest
|
|
Posted: Sun Feb 15, 2009 9:05 am |
|
|
Yes.
This is why it is _vital_ to read the data sheet.
The compiler can only do things that the hardware supports. The 1220 says:
"A single control bit can turn on all the pull-ups".
No individual pull-ups.
If you need individual pull-ups, then you have to search the data sheets, to find a model that has this feature, and everything else you need. However, much simpler to just add external pull-ups...
Best Wishes |
|
|
|
|
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
|