PIC (16F627A) inverted inputs

inputpic

I'm having problem with inputs of my PIC.

There is somethink like "default value" on all inputs set to logical 1 so if I want to change the state I need to pass GND.

How can I turn it "otherwise"? This is begining of my code:

#include <htc.h>
#include <pic.h>
#include <pic16f627a.h>

__CONFIG(WDTE_OFF & PWRTE_OFF & FOSC_INTOSCCLK & MCLRE_OFF & BOREN_OFF & LVP_OFF & CPD_OFF & CP_OFF);

int main (void)
{
    unsigned int i, j;

    unsigned short count = 0;

    TRISA = 0;
    TRISB = 0b11110000;
    PORTA = 0;
    PORTB = 0;
    nRBPU = 0;
    CMCONbits.CM = 7;
    ...

I don't understand electronics very much and I'm also kind of new to programming in C.

Thank you for any help.

Best Answer

This phenomenon is known as a pullup resistor. As seen on the wikipedia page, it is widely used in conjunction with a physical switch. When pressed, the switch "pulls" the input low, overcoming the resistor's high impedance.

Also, on some MCUs there is an option to invert the pin's function. For example, on the AVR XMega, you can configure it so that both input and output will be inverted. I am not sure whether this specific PIC supports such feature. You'll have to dig through the datasheet.