cmicrocontrollerpicled

read port RB7 or other port from PICF184550 in program language C


I'm using the picdem F184550, I want to read the value of the led, I'm using the mplab ide v8.63 with a C compiler. but I don't have a idea how to interface with the port RB7 where my led with a resistor is connected to. The question is, how can I read the port RB7 where my led is connected to in the program language C. thanks! (see pictureenter image description here


Solution

  • This depends on the compiling suite you are using.

    Those provided by Microchip (C18 for 18F MCUs) usually define all available ports & registers in a header file specific to your device (something like p18F4550.h in your case).

    In this header, you will have a structure definition corresponding to your specific port register. You can access to your specific RB7 I/O,within the following field : PORTBbits.RB7