generic26kconfig.c 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*-------------------------------------------------------------------------
  2. config.c - PIC configuration words
  3. This library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. This library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with this library; if not, write to the Free Software
  13. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  14. -------------------------------------------------------------------------*/
  15. #include <pic18fregs.h>
  16. /* Generic Setup() */
  17. void Generic26kSetup()
  18. {
  19. OSCCON=0b01110000;
  20. OSCTUNEbits.PLLEN=1;
  21. #if UART_PORT==1
  22. ANSELCbits.ANSC7=0; //enable digital input buffer for RX pin
  23. #endif
  24. TRISA=0xff;
  25. TRISB=0xff;
  26. TRISC=0xff;
  27. TRISE=0xff;
  28. IOCB=0; //disable all 4 portB "interrupt on change"
  29. INTCON2bits.RBPU=0; //enable PORTB weak pullups
  30. }
  31. #ifdef BOOTLOADER
  32. /* Set the PIC config words */
  33. __code char __at __CONFIG1H _conf1 = _FOSC_INTIO67_1H // Internal oscillator block
  34. & _PLLCFG_ON_1H // Oscillator multiplied by 4
  35. & _PRICLKEN_ON_1H // Primary clock enabled
  36. & _FCMEN_OFF_1H // Fail-Safe Clock Monitor disabled
  37. & _IESO_OFF_1H; // Oscillator Switchover mode disabled
  38. __code char __at __CONFIG2L _conf2 = _PWRTEN_ON_2L // Power up timer enabled
  39. & _BOREN_ON_2L // Brown-out Reset enabled and controlled by software (SBOREN is enabled)
  40. & _BORV_285_2L; // VBOR set to 2.85 V nominal
  41. __code char __at __CONFIG2H _conf3 = _WDTEN_SWON_2H // WDT is controlled by SWDTEN bit of the WDTCON register
  42. & _WDTPS_256_2H; // 1:256 = 1.024s
  43. __code char __at __CONFIG4L _conf5 = //_STVREN_OFF_4L // Stack full/underflow will not cause Reset
  44. _STVREN_ON_4L // Stack full/underflow will cause Reset
  45. & _LVP_OFF_4L // Single-Supply ICSP disabled
  46. & _XINST_OFF_4L // Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
  47. & _DEBUG_OFF_4L; // Disabled
  48. __code char __at __CONFIG5L _conf6 = _CP0_OFF_5L // Block 0 (000800-003FFFh) not code-protected
  49. & _CP1_OFF_5L // Block 1 (004000-007FFFh) not code-protected
  50. & _CP2_OFF_5L // Block 2 (008000-00BFFFh) not code-protected
  51. & _CP3_OFF_5L ; // Block 3 (00C000-00FFFFh) not code-protected
  52. __code char __at __CONFIG5H _conf7 = _CPB_OFF_5H // Boot block (000000-0007FFh) not code-protected
  53. & _CPD_OFF_5H; // Data EEPROM not code-protected
  54. __code char __at __CONFIG6L _conf8 = 0xff; // no code protection at all
  55. __code char __at __CONFIG6H _conf9 = 0xff;
  56. __code char __at __CONFIG7L _conf10 = 0xff;
  57. __code char __at __CONFIG7H _conf11 = 0xff;
  58. #endif //BOOTLOADER