/** Generated main.c file from MPLAB Code Configurator @Company Microchip Technology Inc. @File Name main.c @Summary This is the generated main.c using PIC24 / dsPIC33 / PIC32MM MCUs. @Description This source file provides main entry point for system initialization and application code development. Generation Information : Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0 Device : PIC24F16KM202 The generated drivers are tested against the following: Compiler : XC16 v1.61 MPLAB : MPLAB X v5.45 */ /* (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this software and any derivatives exclusively with Microchip products. THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE TERMS. */ // Configuration bits: selected in the GUI // FBS #pragma config BWRP = OFF //Boot Segment Write Protect->Disabled #pragma config BSS = OFF //Boot segment Protect->No boot program flash segment // FGS #pragma config GWRP = OFF //General Segment Write Protect->General segment may be written #pragma config GCP = OFF //General Segment Code Protect->No Protection // FOSCSEL #pragma config FNOSC = FRC // Oscillator Select (Fast RC Oscillator (FRC)) #pragma config SOSCSRC = ANA //SOSC Source Type->Analog Mode for use with crystal #pragma config LPRCSEL = HP //LPRC Oscillator Power and Accuracy->High Power, High Accuracy Mode #pragma config IESO = OFF //Internal External Switch Over bit->Internal External Switchover mode disabled (Two-speed Start-up disabled) // FOSC #pragma config POSCMOD = NONE //Primary Oscillator Configuration bits->Primary oscillator disabled #pragma config OSCIOFNC = IO //CLKO Enable Configuration bit->Port I/O enabled (CLKO disabled) #pragma config POSCFREQ = HS //Primary Oscillator Frequency Range Configuration bits->Primary oscillator/external clock input frequency greater than 8MHz #pragma config SOSCSEL = SOSCHP //SOSC Power Selection Configuration bits->Secondary Oscillator configured for high-power operation #pragma config FCKSM = CSDCMD //Clock Switching and Monitor Selection->Both Clock Switching and Fail-safe Clock Monitor are disabled // FWDT #pragma config WDTPS = PS32768 //Watchdog Timer Postscale Select bits->1:32768 #pragma config FWPSA = PR128 //WDT Prescaler bit->WDT prescaler ratio of 1:128 #pragma config FWDTEN = OFF //Watchdog Timer Enable bits->WDT disabled in hardware; SWDTEN bit disabled #pragma config WINDIS = OFF //Windowed Watchdog Timer Disable bit->Standard WDT selected(windowed WDT disabled) // FPOR #pragma config BOREN = BOR3 //Brown-out Reset Enable bits->Brown-out Reset enabled in hardware, SBOREN bit disabled #pragma config PWRTEN = ON //Power-up Timer Enable bit->PWRT enabled #pragma config I2C1SEL = PRI //Alternate I2C1 Pin Mapping bit->Use Default SCL1/SDA1 Pins For I2C1 #pragma config BORV = V18 //Brown-out Reset Voltage bits->Brown-out Reset set to lowest voltage (1.8V) #pragma config MCLRE = ON //MCLR Pin Enable bit->RA5 input pin disabled, MCLR pin enabled // FICD #pragma config ICS = PGx1 //ICD Pin Placement Select bits->EMUC/EMUD share PGC1/PGD1 #define FCY 8000000UL /** Section: Included Files */ #include #include "libpic30.h" /* Main application */ int main(void) { // initialize the device /**************************************************************************** * Setting the Output Latch SFR(s) ***************************************************************************/ LATA = 0x0000; //Alle Ausgänge auf Low LATB = 0x0000; /**************************************************************************** * Setting the GPIO Direction SFR(s) ***************************************************************************/ TRISA = 0x0000; //Alle Pins auf Ausgang TRISB = 0x0000; /**************************************************************************** * Setting the Weak Pull Up and Weak Pull Down SFR(s) ***************************************************************************/ CNPD1 = 0x0000; //Alle Pull-Up und Pull-Down aus CNPD2 = 0x0000; CNPU1 = 0x0000; CNPU2 = 0x0000; /**************************************************************************** * Setting the Open Drain SFR(s) ***************************************************************************/ ODCA = 0x0000; //Open-Drain deaktiviert ODCB = 0x0000; /**************************************************************************** * Setting the Analog/Digital Configuration SFR(s) ***************************************************************************/ ANSA = 0x0000; //Alle Pins digital ANSB = 0x0000; CLKDIVbits.ROI = 0; //ROI disabled CLKDIVbits.DOZE2 = 0; CLKDIVbits.DOZE1 = 0; //DOZE 1:1 CLKDIVbits.DOZE0 = 0; CLKDIVbits.DOZEN = 0; //DOZEN disabled CLKDIVbits.RCDIV2 = 0; CLKDIVbits.RCDIV1 = 0; //RCDIV FRC/2 CLKDIVbits.RCDIV0 = 1; OSCTUN = 0x00; //TUN Center frequency REFOCONbits.ROEN = 0; //ROEN disabled REFOCONbits.ROSSLP = 0; //ROSSLP disabled REFOCONbits.ROSEL = 0; //ROSEL FOSC REFOCONbits.RODIV3 = 0; REFOCONbits.RODIV2 = 0; //RODIV 0 REFOCONbits.RODIV1 = 0; REFOCONbits.RODIV0 = 0; PMD1 = 0xFFFF; PMD2 = 0xFFFF; PMD3 = 0xFFFF; PMD4 = 0xFFFF; //gesamte Peripherie deaktiviert PMD6 = 0xFFFF; PMD8 = 0xFFFF; //COSC -> Read only 0b 000 ; //NOSC -> FRC 0b 000 ; //CLKLOCK -> disabled 0b 0 ; //LOCK -> Read only 0b 0 ; //CF -> Read only 0b 0 ; //SOSCDRV -> Config Bit 0b 0 ; //SOSCEN -> disabled 0b 0 ; //OSWEN -> Switch complete 0b 0; //Resultat 0b0000000000000000; __builtin_write_OSCCONH((uint8_t) (0x00)); __builtin_write_OSCCONL((uint8_t) (0x00)); U2MODEbits.UARTEN = 0; //UART2 disabled U2MODEbits.UEN1 = 0; //UART2-Pins nur RX und TX am UART, CTS, RTS und BCLK als IO U2MODEbits.UEN0 = 0; U2STAbits.UTXEN = 0; //Transmit disabled while (1) { // Add your application code LATA = 0xFFFF; LATB = 0xFFFF; __delay_ms(2000); LATA = 0x0000; LATB = 0x0000; __delay_ms(2000); } return 1; } /** End of File */