7/30/2019
Basys MX3 Reference Manual [Reference.Digilentinc]
https://reference.digilentinc.com/reference/microprocessor/basys-mx3/reference-manual?_ga=2.68739409.1349070004.1564406803-1961480359.…
15/52
Table 4.1. Switches connectivity.
Label
Schematic Name
PIC32 Pin
Pin Shared With
Description
SW0
SW0
RPF3/RF3
Switch 0
SW1
SW1
RPF5/PMA8/RF5
Switch 1
SW2
SW2
RPF4/PMA9/RF4
Switch 2
SW3
SW3
RPD15/RD15
Switch 3
SW4
SW4
RPD14/RD14
Switch 4
SW5
SW5
AN11/PMA12/RB11
Switch 5
SW6
SW6
CVREFOUT/AN10/RPB10/CTED11PMA13/RB10
Switch 6
SW7
SW7
AN9/RPB9/CTED4/RB9
TRIG_2
Switch 7
All the pins must be defined as digital input: their corresponding TRIS bit must be set to 1, and analog function must be disabled for pins
routed to SW5, SW6 and SW7.
TRISFbits.TRISF3 = 1; // RF3 (SW0) configured as input
TRISFbits.TRISF5 = 1; // RF5 (SW1) configured as input
TRISFbits.TRISF4 = 1; // RF4 (SW2) configured as input
TRISDbits.TRISD15 = 1; // RD15 (SW3) configured as input
TRISDbits.TRISD14 = 1; // RD14 (SW4) configured as input
TRISBbits.TRISB11 = 1; // RB11 (SW5) configured as input
ANSELBbits.ANSB11 = 0; // RB11 (SW5) disabled analog
TRISBbits.TRISB10 = 1; // RB10 (SW6) configured as input
ANSELBbits.ANSB10 = 0; // RB10 (SW6) disabled analog
TRISBbits.TRISB9 = 1; // RB9 (SW7) configured as input
ANSELBbits.ANSB9 = 0; // RB9 (SW7) disabled analog
In order to read the switches, the user needs to read the corresponding digital input pin. A value of 1 indicates the switch as being on (high)
or 0 indicates the switch as being off (low).
val = PORTFbits.RF3; // read SW0
val = PORTFbits.RF5; // read SW1
val = PORTFbits.RF4; // read SW2
val = PORTDbits.RD15; // read SW3
val = PORTDbits.RD14; // read SW4
val = PORTBbits.RB11; // read SW5
val = PORTBbits.RB10; // read SW6
val = PORTBbits.RB9; // read SW7
4.1. Connectivity
4.2. Functionality