Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.07 KB | None | 0 0
  1. // FSEC
  2. #pragma config BWRP = OFF // Boot Segment Write-Protect bit (Boot Segment may be written)
  3. #pragma config BSS = DISABLED // Boot Segment Code-Protect Level bits (No Protection (other than BWRP))
  4. #pragma config BSEN = OFF // Boot Segment Control bit (No Boot Segment)
  5. #pragma config GWRP = OFF // General Segment Write-Protect bit (General Segment may be written)
  6. #pragma config GSS = DISABLED // General Segment Code-Protect Level bits (No Protection (other than GWRP))
  7. #pragma config CWRP = OFF // Configuration Segment Write-Protect bit (Configuration Segment may be written)
  8. #pragma config CSS = DISABLED // Configuration Segment Code-Protect Level bits (No Protection (other than CWRP))
  9. #pragma config AIVTDIS = OFF // Alternate Interrupt Vector Table bit (Disabled AIVT)
  10.  
  11. // FBSLIM
  12. #pragma config BSLIM = 0x1FFF // Boot Segment Flash Page Address Limit bits (Boot Segment Flash page address limit)
  13.  
  14. // FSIGN
  15.  
  16. // FOSCSEL (Select Internal FRC at POR)
  17. #pragma config FNOSC = FRC // Oscillator Source Selection (Fast RC Oscillator)
  18. #pragma config IESO = OFF // Two-speed Oscillator Start-up Disabled
  19.  
  20. // FOSC
  21. #pragma config POSCMD = NONE // Primary Oscillator Mode Select bits (Primary Oscillator disabled)
  22. #pragma config OSCIOFNC = ON // OSC2 Pin is I/O
  23. #pragma config IOL1WAY = OFF // Peripheral pin select configuration bit (Allow multiple reconfigurations)
  24. #pragma config FCKSM = CSECME // Clock Switching Mode bits (Both Clock switching and Fail-safe Clock Monitor are enabled)
  25. #pragma config PLLKEN = ON // PLL Lock Enable Bit (Clock switch will wait for the PLL lock signal)
  26.  
  27. // FWDT
  28. #pragma config WDTPOST = PS32768 // Watchdog Timer Postscaler bits (1:32,768)
  29. #pragma config WDTPRE = PR128 // Watchdog Timer Prescaler bit (1:128)
  30. #pragma config WDTEN = OFF // Watchdog Timer Enable bits (WDT and SWDTEN disabled)
  31. #pragma config WINDIS = OFF // Watchdog Timer Window Enable bit (Watchdog Timer in Non-Window mode)
  32. #pragma config WDTWIN = WIN25 // Watchdog Timer Window Select bits (WDT Window is 25% of WDT period)
  33.  
  34. // FICD
  35. #pragma config ICS = PGD1 // ICD Communication Channel Select bits (Communicate on PGEC1 and PGED1)
  36. #pragma config JTAGEN = OFF // JTAG Enable bit (JTAG is disabled)
  37. #pragma config BTSWP = OFF // BOOTSWP Instruction Enable/Disable bit (BOOTSWP instruction is disabled)
  38.  
  39. // FDEVOPT
  40. #pragma config PWMLOCK = OFF // PWMx Lock Enable bit (PWM registers may be written without key sequence)
  41. #pragma config ALTI2C1 = OFF // Alternate I2C1 Pin bit (I2C1 mapped to SDA1/SCL1 pins)
  42. #pragma config ALTI2C2 = OFF // Alternate I2C2 Pin bit (I2C2 mapped to SDA2/SCL2 pins)
  43. #pragma config DBCC = OFF // DACx Output Cross Connection bit (No Cross Connection between DAC outputs)
  44.  
  45. // FALTREG
  46. #pragma config CTXT1 = OFF // Specifies Interrupt Priority Level (IPL) Associated to Alternate Working Register 1 bits (Not Assigned)
  47. #pragma config CTXT2 = OFF // Specifies Interrupt Priority Level (IPL) Associated to Alternate Working Register 2 bits (Not Assigned)
  48.  
  49. // FBTSEQ
  50. #pragma config BSEQ = 0xFFF // Relative value defining which partition will be active after device Reset; the partition containing a lower boot number will be active (Boot Sequence Number bits)
  51. #pragma config IBSEQ = 0xFFF // The one's complement of BSEQ; must be calculated by the user and written during device programming. (Inverse Boot Sequence Number bits)
  52.  
  53. #include <xc.h>
  54. #include <stdlib.h>
  55. #include <libpic30.h>
  56. #include <pps.h>
  57. #include <uart.h>
  58. #include <stdint.h>
  59.  
  60. int main(int argc, char** argv) {
  61. PLLFBD = 74; // M = PLLFBD + 2 = 76
  62. CLKDIVbits.PLLPOST = 0; // N2 = 2
  63. CLKDIVbits.PLLPRE = 0; // N1 = 2
  64.  
  65. __builtin_write_OSCCONH(0x01);
  66. __builtin_write_OSCCONL(OSCCON | 0x01);
  67. while(OSCCONbits.COSC != 0);
  68. while(OSCCONbits.LOCK != 1);
  69.  
  70. ACLKCONbits.FRCSEL = 1;
  71. ACLKCONbits.SELACLK = 1;
  72. ACLKCONbits.APSTSCLR = 7;
  73. ACLKCONbits.ENAPLL = 1;
  74. while(ACLKCONbits.APLLCK != 1);
  75.  
  76. INTCON1bits.NSTDIS = 0;
  77.  
  78. TRISBbits.TRISB5 = 0;
  79. LATBbits.LATB5 = 1;
  80. while(1){
  81. LATBbits.LATB5= 0;
  82. LATBbits.LATB5= 1;
  83. LATBbits.LATB5= 0;
  84. LATBbits.LATB5= 1;
  85. LATBbits.LATB5= 0;
  86. LATBbits.LATB5= 1;
  87. LATBbits.LATB5= 0;
  88. LATBbits.LATB5= 1;
  89. LATBbits.LATB5= 0;
  90. LATBbits.LATB5= 1;
  91. LATBbits.LATB5= 0;
  92. LATBbits.LATB5= 1;
  93. LATBbits.LATB5= 0;
  94. LATBbits.LATB5= 1;
  95. LATBbits.LATB5= 0;
  96. LATBbits.LATB5= 1;
  97. LATBbits.LATB5= 0;
  98. LATBbits.LATB5= 1;
  99. LATBbits.LATB5= 0;
  100. LATBbits.LATB5= 1;
  101. LATBbits.LATB5= 0;
  102. LATBbits.LATB5= 1;
  103. LATBbits.LATB5= 0;
  104. LATBbits.LATB5= 1;
  105. LATBbits.LATB5= 0;
  106. LATBbits.LATB5= 1;
  107. }
  108.  
  109. return (EXIT_SUCCESS);
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement