Guest User

Untitled

a guest
Mar 19th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. // The wiring is the recommended minimum connections with an additional resistor
  2. // and LED. The positive lead of the LED is connected to VDD and the negative
  3. // lead to RB3 through a 220 ohm resistor.
  4.  
  5. // Tested on:
  6. // PIC32MX270F256B
  7. // MPLAB X IDE v4.15
  8. // XC32 v2.05
  9.  
  10. #include "xc.h"
  11. #include "p32xxxx.h"
  12.  
  13. #pragma config FWDTEN = OFF // Turn off watchdog timer
  14. #pragma config FNOSC = FRCPLL // Select 8 MHz internal Fast RC (FRC) oscillator with PLL
  15. #pragma config FPLLIDIV = DIV_2 // Divide PLL input (FRC) to get into required range [4 MHz, 5 MHz]
  16. #pragma config FPLLMUL = MUL_15 // PLL Multiplier
  17. #pragma config FPLLODIV = DIV_1 // PLL Output Divider
  18. #pragma config FPBDIV = DIV_1 // Peripheral Clock divisor
  19.  
  20. // Operating at 8 / 2 * 15 / 1 = 60 MHz
  21.  
  22. void led_on() {
  23. LATBbits.LATB3 = 0;
  24. }
  25.  
  26. void led_off() {
  27. LATBbits.LATB3 = 1;
  28. }
  29.  
  30. void delay() {
  31. int i;
  32. for (i = 0; i < 1400000; i += 1);
  33. }
  34.  
  35. int main() {
  36. ANSELBbits.ANSB3 = 0;// RB3 is digital
  37. TRISBbits.TRISB3 = 0;// RB3 is output
  38.  
  39. while (1) {
  40. delay();
  41. led_off();
  42. delay();
  43. led_on();
  44. }
  45.  
  46. return 0;
  47. }
Add Comment
Please, Sign In to add comment