Blink a LED on a PIC32MX250F256L dev board. Main loop timing by millisecond timer interrupt generated by Timer 1. 500Hz square wave on RD11, pin 71. LED on RB9, pin 33, blinks at 1Hz. UART1 on pins 89 and 90 transmits at 9600 baud. Tact switch or pushbutton on RA1, pin 38, with pull-up resistor. Three channels of PWM on OC1, OC2, and OC3 to drive an RGB LED.
Later, we'll have:
- SPI channels configured to send data
Name | Port | Pin | PIC32MX795F512L pin | Activity |
---|---|---|---|---|
LED | RB9 | 33 | 33 | LED, active-LOW |
SQWAVE | RD11 | 71 | 71 | 500Hz |
U1TX | RG0 | 90 | 53 (RF8) | UART1 transmit |
U1RX | RG1 | 89 | 52 (RF2) | UART1 receive |
BUTTON | RA1 | 38 | 38 | Button, active-LOW |
RED | RD0 | 72 | 72 (RD0/OC1) | Red LED PWM |
GREEN | RD1 | 76 | 76 (RD1/OC2) | Green LED PWM |
BLUE | RD2 | 77 | 77 (RD2/OC3) | Blue LED PWM |
PIC32 pin numbers are for the 100-pin package.
Note that the PIC32MX795F512L does not have PPS and therefore has all the peripheral pins pre-assigned. It is not possible to assign U1TX to RF8 via PPS on the chips which do have it. Which means that we have the plain GPIOs assigned the same, but the UART assigned differently between the two classes of chip.
LED on RB9 lights when the pin is pulled LOW. RGB LED lights when the PWM pin is HIGH.
Name | PIC32 | RAM | Flash | Clock | Notes |
---|---|---|---|---|---|
default | PIC32MX250F256L | 32k | 256k+3k | 48MHz | The usual PIC32 on the Reach Robotics Leg Test Board |
MoreRAM | PIC32MX570F512L | 64k | 512k+3k | 48MHz | Modified board with 64k RAM |
Faster | PIC32MX795F512L | 128k | 512k+12k | 80MHz | Modified board with 80MHz and 128k RAM |
The PLL setup for the PIC32MX795F512L is different from the other two so that we get an 80MHz SYSCLK. This makes the PIC32MX795F512L about 4.5 times faster than the other PIC32s, once we have switched on the cache and the prefetch buffer in 'initMCU()'. But we must divide SYSCLK by two to get a 40MHz PBCLK which is within the limits of the chip. A #define in the code (FPBCLK) is used to calculate timer settings and baud rates.
MPLAB X V3.45 and 'xc32' V2.15. These are quite old versions now, so I really ought to upgrade!
Microchip ICD3. Other programmers should work, e.g. ICD4 or PICkit4.