Last active
June 15, 2022 13:15
-
-
Save rk76feWF/21270fd5823afb996a7deae2ed2ac433 to your computer and use it in GitHub Desktop.
Lチカ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef CONFIG_H | |
#define CONFIG_H | |
// PIC24FJ64GB002 Configuration Bit Settings | |
// 'C' source line config statements | |
// CONFIG4 | |
#pragma config DSWDTPS = DSWDTPSF // DSWDT Postscale Select (1:2,147,483,648 (25.7 days)) | |
#pragma config DSWDTOSC = LPRC // Deep Sleep Watchdog Timer Oscillator Select (DSWDT uses Low Power RC Oscillator (LPRC)) | |
#pragma config RTCOSC = SOSC // RTCC Reference Oscillator Select (RTCC uses Secondary Oscillator (SOSC)) | |
#pragma config DSBOREN = ON // Deep Sleep BOR Enable bit (BOR enabled in Deep Sleep) | |
#pragma config DSWDTEN = ON // Deep Sleep Watchdog Timer (DSWDT enabled) | |
// CONFIG3 | |
#pragma config WPFP = WPFP63 // Write Protection Flash Page Segment Boundary (Highest Page (same as page 42)) | |
#pragma config SOSCSEL = IO // Secondary Oscillator Pin Mode Select (SOSC pins in Default (high drive-strength) Oscillator Mode) | |
#pragma config WUTSEL = LEG // Voltage Regulator Wake-up Time Select (Default regulator start-up time used) | |
#pragma config WPDIS = WPDIS // Segment Write Protection Disable (Segmented code protection disabled) | |
#pragma config WPCFG = WPCFGDIS // Write Protect Configuration Page Select (Last page and Flash Configuration words are unprotected) | |
#pragma config WPEND = WPENDMEM // Segment Write Protection End Page Select (Write Protect from WPFP to the last page of memory) | |
// CONFIG2 | |
#pragma config POSCMOD = NONE // Primary Oscillator Select (Primary Oscillator disabled) | |
#pragma config I2C1SEL = PRI // I2C1 Pin Select bit (Use default SCL1/SDA1 pins for I2C1 ) | |
#pragma config IOL1WAY = OFF // IOLOCK One-Way Set Enable (The IOLOCK bit can be set and cleared using the unlock sequence) | |
#pragma config OSCIOFNC = ON // OSCO Pin Configuration (OSCO pin functions as port I/O (RA3)) | |
#pragma config FCKSM = CSDCMD // Clock Switching and Fail-Safe Clock Monitor (Sw Disabled, Mon Disabled) | |
#pragma config FNOSC = FRC // Initial Oscillator Select (Fast RC Oscillator with Postscaler and PLL module (FRCPLL)) | |
#pragma config PLL96MHZ = ON // 96MHz PLL Startup Select (96 MHz PLL Startup is enabled automatically on start-up) | |
#pragma config PLLDIV = DIV12 // USB 96 MHz PLL Prescaler Select (Oscillator input divided by 12 (48 MHz input)) | |
#pragma config IESO = OFF // Internal External Switchover (IESO mode (Two-Speed Start-up) disabled) | |
// CONFIG1 | |
#pragma config WDTPS = PS1 // Watchdog Timer Postscaler (1:1) | |
#pragma config FWPSA = PR32 // WDT Prescaler (Prescaler ratio of 1:32) | |
#pragma config WINDIS = OFF // Windowed WDT (Standard Watchdog Timer enabled,(Windowed-mode is disabled)) | |
#pragma config FWDTEN = OFF // Watchdog Timer (Watchdog Timer is disabled) | |
#pragma config ICS = PGx1 // Emulator Pin Placement Select bits (Emulator functions are shared with PGEC1/PGED1) | |
#pragma config GWRP = OFF // General Segment Write Protect (Writes to program memory are allowed) | |
#pragma config GCP = OFF // General Segment Code Protect (Code protection is disabled) | |
#pragma config JTAGEN = OFF // JTAG Port Enable (JTAG port is disabled) | |
// #pragma config statements should precede project file includes. | |
// Use project enums instead of #define for ON and OFF. | |
#endif /* CONFIG_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <xc.h> | |
#include "config.h" | |
#define FCY 4000000UL | |
#include <libpic30.h> | |
#define LED1 LATBbits.LATB5 | |
void setup() | |
{ | |
OSCCON = 0x0000; | |
CLKDIV = 0x0000; | |
AD1PCFG = 0xffff; | |
TRISA = 0xffff; | |
TRISB = 0xffff; | |
TRISBbits.TRISB5 = 0; | |
} | |
int main(void) | |
{ | |
setup(); | |
while(1) | |
{ | |
LED1 = ~LED1; | |
__delay_ms(1000); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment