Beispiel #1
0
int main()
{
	#if defined(PIC32_PINGUINO) || defined(PIC32_PINGUINO_OTG)
	TRISDbits.TRISD9=1;		// because PORTB is shared with SDA on Olimex board
	TRISDbits.TRISD10=1;		// because PORTB is shared with SCL on Olimex board
	#endif	

	SystemConfig(80000000);	// default clock frequency is 80Mhz
									// default peripheral freq. is 40MHz (cf. system.c)

	// All pins of PORTB as digital IOs
#ifdef __32MX220F032D__
	ANSELA = 0;
	ANSELB = 0;
	ANSELC = 0;
#else
	AD1PCFG = 0xFFFF;
#endif
	
	#ifdef __ANALOG__
	analog_init();
	#endif

	#ifdef __MILLIS__
	millis_init();
	#endif

	#ifdef __PWM__
	PWM_init();
	#endif    

	#ifdef __USBCDC
	CDC_init();
	#endif    

	#ifdef __RTCC__
	RTCC_init();
	#endif    
	
	setup();

	while (1)
	{
		#ifdef __USBCDC
		CDCTxService();
		#endif    
		loop();
	}

	return(0);    
}
Beispiel #2
0
int main()
{
	// default peripheral freq. is CPUCoreFrequency / 2 (cf. system.c)
	#if defined(__32MX220F032D__)||defined(__32MX250F128B__)||defined(__32MX220F032B__)
	SystemConfig(40000000);	// default clock frequency is 40Mhz
	#else
	SystemConfig(80000000);	// default clock frequency is 80Mhz
	#endif

	IOsetSpecial();
	IOsetDigital();
	IOsetRemap();

	#ifdef __ANALOG__
	analog_init();
	#endif

	#ifdef __MILLIS__
	millis_init();
	#endif

	#ifdef __PWM__
	PWM_init();
	#endif    

	#ifdef __USBCDC
	CDC_init();
	#endif    

	#ifdef __RTCC__
	RTCC_init();
	#endif    
	
	setup();

	while (1)
	{
		#ifdef __USBCDC
			#if defined(__32MX220F032D__)||defined(__32MX250F128B__)||defined(__32MX220F032B__)
				USB_Service( );
			#else
				CDCTxService();
			#endif
		#endif
 
		loop();
	}

	return(0);    
}
Beispiel #3
0
void main_init(void) {
    OSC_init();
    TRISA = 0b11100111; // SWB,SWG,SWR,Vcap,x,ADCB,ADCG,ADCR
    TRISB = 0b00000000; // PGD,PGC,x,PWMW,x,PWMB,PWMG,PWMR
    TRISC = 0b10111010; // RX,TX,D+,D-,Vusb,x,T1OSI,T1OSO
    ANCON0 = 0b11111000; // AN2,AN1,AN0 is analog
    ANCON1 = 0b00011111; // all digital
    INTCON2bits.RBPU = 0; // PORTB Pull-Up Enable

    timer0_init(8); // ?
    timer1_init(0, T1OSC); // ?
    timer3_init(2); // button?
    RTCC_init();
    PWM_init(PR_VALUE); //250 is 3kHz

    USB_CDC_init();
}
Beispiel #4
0
void main_init(void) {
    OSC_init();
    TRISA = 0b00010000; // x,x,x,Vcap,x,x,x,x
    TRISB = 0b00110001; // x,x,SDA,SCL,x,x,x,x
    TRISC = 0b10111010; // RX,TX,D+,D-,Vusb,LED,T1OSI,T1OSO
    ANCON0 = 0b11111111; // xxx,xxx,xxx,RA5,RA3,RA2,RA1,RA0
    ANCON1 = 0b00011111; // VBG,xxx,xxx,RB0,RC2,RB1,RB3,RB2
    INTCON2bits.RBPU = 0; // Pull-up enable

    timer0_init(6);
    timer1_init(0, T1OSC);
    timer3_init(2); // button
    I2C_LCD_init();
    RTCC_init();
    USB_CDC_init();
    UART_init();
}