void main()
{
#ifdef OSCILLATEUR_INTERNE
// 1MHz par defaut car OSCON RAZ au reset
OSCCON=0;
// OSCCON=0b01110000;
// OSCCONbits.IRCF2=1; //HFINTOSC - (16 MHz)
// OSCCONbits.IRCF1=1;
// OSCCONbits.IRCF0=1;
OSCCON.IRCF2=1; //HFINTOSC - (4 MHz)
OSCCON.IRCF1=0;
OSCCON.IRCF0=1;
// SCS<1:0> System Clock Select bit
// 1x = Internal oscillator block
// 01 = Secondary (SOSC) oscillator
// 00 = Primary clock (determined by FOSC<3:0> in CONFIG1H).
OSCCON.SCS1=1;
OSCCON.SCS0=0;
OSCTUNE=0;
OSCTUNE.PLLEN=0; // 1= avec PLL => 64Mhz ou 40Mhz 0 =sans PLL => 16Mhz ou 10Mhz
#else
// FOSC=Q=20MHz
#endif
Init_UART1();
Delay_ms(10);
Send_UART1(10);Send_UART1(13); // CRLF
UART1_Print_CText("Debut de test UART1 RC6=TX RC7=RX 19200,8,N,1 Fosc=4 Mhz\r\n");
Send_UART1(65);Send_UART1(66);Send_UART1(67); // send ABC
Send_UART1(10);Send_UART1(13); // CRLF
for (i=65;i<128;i++)
{
Send_UART1((unsigned char)i);
}
Send_UART1(10);Send_UART1(13);
UART1_Print_CText("Fin test UART1 \r\n");
Send_UART1(10);Send_UART1(13);
UART1_Print_CText("Debut de test UART2 ..\r\n");
Init_UART2();
Delay_ms(10);
Send_UART2(10);Send_UART2(13);
UART2_Print_CText("Debut de test UART2 RB6=TX RB7=RX 19200,8,N,1 Fosc=4 Mhz\r\n");
Send_UART2(65);Send_UART2(66);Send_UART2(67);
Send_UART2(10);Send_UART2(13); // CRLF
for (i=65;i<128;i++)
{
Send_UART2((unsigned char)i);
}
Send_UART2(10);Send_UART2(13);
UART2_Print_CText("Fin test UART2 \r\n");
Send_UART2(10);Send_UART2(13);
while(1);
}