View RSS Feed

Gianni

MuIn USB - How to connect Switches on PortB

Rate this Entry
If you're going to connect some switches on your MuIn USB (using your firmware), you can consider using PORTB since it has integrated pull-up resistors: one pin of the switch will be connected to GND and other pin on PORTB Input. You'll detect the button pressed with some instructions like those:

if (!LATBbits.LATBx) // x=0...7
{
// instructions to execute if button pressed
}
else
{
// instructions to execute if button not pressed
}

To activate integrated pullup resistors you must include portb.h library in top of your program:

#include <portb.h>

and the activate pullup resistors with dedicate function:

EnablePullups();

Notice tha inputs B0 and B1 are also used by I2C peripheral. If you want use them for switches, you must solder the I2C jumper-pads on the botton of MuIN USB however: solder pad 1 with pad 2 to connect an external pullup resistor on B0 and B1.

If you don't do this, pushing a button on B0 will cause also B1 toggling and vice-versa.
Tags: muin, rb0, rb1, switch, usb Add / Edit Tags
Categories
Uncategorized

Comments