Guest User

Untitled

a guest
Jan 17th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. /*
  2. * file: main.c
  3. * target: PIC18LF45K50
  4. * IDE: MPLABX v5.10
  5. * Compiler: XC8 v1.45
  6. *
  7. * PIC18LF45K50
  8. * +---------:_:---------+
  9. * 10K pull-up RE3 -> : 1 VPP PGD 40 : <> RB7
  10. * RA0 <> : 2 PGC 39 : <> RB6
  11. * LED RA1 <> : 3 38 : <> RB5
  12. * RA2 <> : 4 37 : <> RB4
  13. * RA3 <> : 5 36 : <> RB3
  14. * RA4 <> : 6 35 : <> RB2
  15. * RA5 <> : 7 34 : <> RB1
  16. * RE0 <> : 8 INT0 33 : <> RB0
  17. * RE1 <> : 9 32 : <- VDD 3v3
  18. * RE2 <> : 10 31 : <- VSS GND
  19. * 3v3 VDD -> : 11 30 : <> RD7
  20. * GND VSS -> : 12 29 : <> RD6
  21. * RA7 <> : 13 OSC1 28 : <> RD5
  22. * RA6 <> : 14 OSC2 27 : <> RD4
  23. * RC0 <> : 15 SOSCO 26 : <> RC7
  24. * RC1 <> : 16 SOSCI 25 : <> RC6
  25. * RC2 <> : 17 CCP1 24 : <> D+
  26. * 3v3 VUSB -> : 18 23 : <> D-
  27. * RD0 <> : 19 22 : <> RD3
  28. * RD1 <> : 20 21 : <> RD2
  29. * +---------------------+
  30. * DIP-40
  31. *
  32. * Description:
  33. *
  34. * This applicaiton toggles the RA1 output hight for 250 millseconds then low for 250 millseconds.
  35. *
  36. * See: https://electronics.stackexchange.com/questions/417447/pic-microcontroller-not-working-without-pickit3
  37. *
  38. * The circuit does not have much going on,Power supply and Pull up resistor
  39. * is connected and Pin-3 is supposed to give out pulses. Configured to work
  40. * with internal oscillator. MCLR pin is pulled up with 10K resistor.
  41. */
  42. #include <xc.h>
  43. /*
  44. * PIC configuration words
  45. */
  46. #pragma config PLLSEL = PLL3X, CFGPLLEN = ON, CPUDIV = NOCLKDIV
  47. #pragma config LS48MHZ = SYS48X8, FOSC = INTOSCIO, PCLKEN = OFF
  48. #pragma config FCMEN = OFF, IESO = OFF, nPWRTEN = OFF, BOREN = OFF
  49. #pragma config BORV = 190, nLPBOR = OFF, WDTEN = SWON, WDTPS = 32768
  50. #pragma config CCP2MX = RC1, PBADEN = OFF, T3CMX = RC0, SDOMX = RB3
  51. #pragma config MCLRE = ON, STVREN = ON, LVP = OFF, ICPRT = OFF
  52. #pragma config XINST = OFF
  53. #pragma config CP0 = OFF, CP1 = OFF, CP2 = OFF, CP3 = OFF
  54. #pragma config CPB = OFF, CPD = OFF
  55. #pragma config WRT0 = OFF, WRT1 = OFF, WRT2 = OFF, WRT3 = OFF
  56. #pragma config WRTC = OFF, WRTB = OFF, WRTD = OFF
  57. #pragma config EBTR0 = OFF, EBTR1 = OFF, EBTR2 = OFF, EBTR3 = OFF
  58. #pragma config EBTRB = OFF
  59.  
  60. /*
  61. * Constants Definition
  62. */
  63. #define _XTAL_FREQ (48000000UL)
  64. /*
  65. * Main application
  66. */
  67. void main( void )
  68. {
  69. INTCON = 0; /* Disable all interrupt sources */
  70. PIE1 = 0;
  71. PIE2 = 0;
  72. INTCON3bits.INT1IE = 0;
  73. INTCON3bits.INT2IE = 0;
  74.  
  75. OSCCON = 0x70; /* set internal oscillator to 16MHz */
  76.  
  77. /*
  78. * Application loop
  79. */
  80. ANSELAbits.ANSA1 = 0; /* make RA1 digital I/O */
  81. TRISAbits.TRISA1 = 0; /* make RA1 digital output */
  82. LATAbits.LATA1 = 0; /* make RA1 output low */
  83. for(;;)
  84. {
  85. LATAbits.LATA1 ^= 1; /* toggle RA1 output */
  86. __delay_ms(250);
  87. }
  88. }
Add Comment
Please, Sign In to add comment