Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // The wiring is the recommended minimum connections with an additional resistor
- // and LED. The positive lead of the LED is connected to VDD and the negative
- // lead to RB3 through a 220 ohm resistor.
- // Tested on:
- // PIC32MX270F256B
- // MPLAB X IDE v4.15
- // XC32 v2.05
- #include "xc.h"
- #include "p32xxxx.h"
- #pragma config FWDTEN = OFF // Turn off watchdog timer
- #pragma config FNOSC = FRCPLL // Select 8 MHz internal Fast RC (FRC) oscillator with PLL
- #pragma config FPLLIDIV = DIV_2 // Divide PLL input (FRC) to get into required range [4 MHz, 5 MHz]
- #pragma config FPLLMUL = MUL_15 // PLL Multiplier
- #pragma config FPLLODIV = DIV_1 // PLL Output Divider
- #pragma config FPBDIV = DIV_1 // Peripheral Clock divisor
- // Operating at 8 / 2 * 15 / 1 = 60 MHz
- void led_on() {
- LATBbits.LATB3 = 0;
- }
- void led_off() {
- LATBbits.LATB3 = 1;
- }
- void delay() {
- int i;
- for (i = 0; i < 1400000; i += 1);
- }
- int main() {
- ANSELBbits.ANSB3 = 0;// RB3 is digital
- TRISBbits.TRISB3 = 0;// RB3 is output
- while (1) {
- delay();
- led_off();
- delay();
- led_on();
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment