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