https://github.com/fubarino/fubarino.github.com/wiki/Fubarino-mini-board-pin-features
Fubarino Mini is the basis for the DIY chipkit and sold by Microchip in a preprogrammed mode with almost the same price as a blank chip. It is no longer necessary to burn the bootlooder into the PIC32 at a price less than US$4, it is very cheap and comes with DIP package which is important for breadboard construction.
Fubarino Mini board pin features
Brian Schmalz edited this page 14 days ago
·
7 revisions
This sample sketch shows all five of the PWM outputs running:
voidsetup() {
}
int x = 0;
voidloop() {
analogWrite(0, x);
analogWrite(4, x);
analogWrite(7, x);
analogWrite(8, x);
analogWrite(9, x);
delay(100);
x = x + 8;
if (x > 255) {
x = 0;
}
}
Note that like most other digital type functions, these default pins can be re-mapped using PPS calls.
Interrupts
The Fubarino Mini has hardware interrupts on pins 24 (non-PPS), 3 (PPS), 0 (PPS), 6 (PPS) and 4 (PPS)
Pin 24 is INT0, Pin 3 is INT1, Pin 0 is INT2, Pin 6 is INT3 and Pin 4 is INT5
Here is a sketch showing how to use these interrupts.
// Move a wire from pin 12 to each of the hardware interrupt pins to show that// they print out the proper message.
#definepinSrc12// used as external interrupt stimulatorvoidint0Handle();
voidint1Handle();
voidint2Handle();
voidint3Handle();
voidint4Handle();
int x;
voidsetup()
{
Serial.begin(9600); // Turn on UART to pidigitalWrite(PIN_LED1, LOW); // Start of with LED offpinMode(PIN_LED1, OUTPUT); // Make LED pin an outputpinMode(PIN_INT0, INPUT); // Interrupt pin must be an inputpinMode(PIN_INT1, INPUT); // Interrupt pin must be an inputpinMode(PIN_INT2, INPUT); // Interrupt pin must be an inputpinMode(PIN_INT3, INPUT); // Interrupt pin must be an inputpinMode(PIN_INT4, INPUT); // Interrupt pin must be an inputdigitalWrite(pinSrc, LOW); // Simulator pin must start lowpinMode(pinSrc, OUTPUT); // And stim pin must be output tooattachInterrupt(0, int0Handle, RISING); // Register interrupt function on Int0attachInterrupt(1, int1Handle, RISING); // Register interrupt function on Int1attachInterrupt(2, int2Handle, RISING); // Register interrupt function on Int2attachInterrupt(3, int3Handle, RISING); // Register interrupt function on Int3attachInterrupt(4, int4Handle, RISING); // Register interrupt function on Int4
}
voidloop()
{
digitalWrite(pinSrc, HIGH); // Set stim pin high (triggers interrupt)delay(1000); // wait half a second
Serial.println("Main loop tick");
digitalWrite(pinSrc, LOW); // Set stim pin lowdelay(1000); // wait another half second
}
// This function gets called when an external interrupt occursvoidint0Handle()
{
digitalWrite(PIN_LED1, !digitalRead(PIN_LED1));
Serial.println("int0Handler() triggered");
}
voidint1Handle()
{
digitalWrite(PIN_LED1, !digitalRead(PIN_LED1));
Serial.println("int1Handler() triggered");
}
voidint2Handle()
{
digitalWrite(PIN_LED1, !digitalRead(PIN_LED1));
Serial.println("int2Handler() triggered");
}
voidint3Handle()
{
digitalWrite(PIN_LED1, !digitalRead(PIN_LED1));
Serial.println("int3Handler() triggered");
}
voidint4Handle()
{
digitalWrite(PIN_LED1, !digitalRead(PIN_LED1));
Serial.println("int4Handler() triggered");
}
PPS Peripheral Pin Select
The PIC32MX250 part used on Fubarino Mini has a Peripheral Pin Select
function for almost all of its digital I/O pins. When writing sketches
for the Fubarino Mini, you have two choices. You can use the default PPS
mappings of the peripheral pins (as listed in the above sections), or,
if you want to change the PPS mapping for a pin r peripheral, you will
need to add your own calls to the PPS mapping system to change from the
default mappings. This is done using the PPS functions (ppsInputSelect()
and ppsOutputSelect()) before trying to use the peripheral. See the example code on the Fubarino Mini Github site for more detailed information.
*Pins 0, 3-16, 17-32
No comments:
Post a Comment