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

port_b_pullups

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



Joined: 01 Aug 2007
Posts: 38
Location: AUckland, NEW ZEALAND

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

port_b_pullups
PostPosted: Sun Feb 15, 2009 4:04 am     Reply with quote

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

View user's profile Send private message Yahoo Messenger

PostPosted: Sun Feb 15, 2009 4:27 am     Reply with quote

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







PostPosted: Sun Feb 15, 2009 9:05 am     Reply with quote

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