Log in

View Full Version : Didn't Like Digital Handling


Anime-niac_2.9
05-02-2007, 13:28
I am used to having 0 mean that the circuit is open and 1 meaning that the circuit is closed, so I did this to the rc digital input portion of ifi_aliases.h:


/* Aliases used to read the pins when used as INPUTS. */
#define rc_dig_in01 !(PORTBbits.RB2) /* external interrupt RB2/INT2 */
#define rc_dig_in02 !(PORTBbits.RB3) /* external interrupt RB3/INT3 */
#define rc_dig_in03 !(PORTBbits.RB4) /* external interrupt-on-change RB4 */
#define rc_dig_in04 !(PORTBbits.RB5) /* external interrupt-on-change RB5 */
#define rc_dig_in05 !(PORTBbits.RB6) /* external interrupt-on-change RB6 */
#define rc_dig_in06 !(PORTBbits.RB7) /* external interrupt-on-change RB7 */
#define rc_dig_in07 !(PORTHbits.RH0)
#define rc_dig_in08 !(PORTHbits.RH1)
#define rc_dig_in09 !(PORTHbits.RH2)
#define rc_dig_in10 !(PORTHbits.RH3)
#define rc_dig_in11 !(PORTJbits.RJ1)
#define rc_dig_in12 !(PORTJbits.RJ2)
#define rc_dig_in13 !(PORTJbits.RJ3)
#define rc_dig_in14 !(PORTCbits.RC0)
#define rc_dig_in15 !(PORTJbits.RJ4)
#define rc_dig_in16 !(PORTJbits.RJ5)
#define rc_dig_in17 !(PORTJbits.RJ6)
#define rc_dig_in18 !(PORTJbits.RJ7

i know it says at the top not to edit the file at all, but I am doing what feels comfortable to me.

feel free to comment my methods

Alan Anderson
05-02-2007, 13:46
You're likely to cause great confusion by redefining things that everyone else programming the robots in MicroChip C understands in a specific way. I suggest instead that you leave the existing #defines alone and create your own aliases for your own use, like this:


/* Digital input aliases that evaluate to 0 when the input is open and 1 when grounded by a switch. */
#define rc_sw01 !(PORTBbits.RB2)
#define rc_sw02 !(PORTBbits.RB3)
#define rc_sw03 !(PORTBbits.RB4)
...