// PIC 18F46K22
#define OSCILLATEUR_INTERNE
#ifdef OSCILLATEUR_INTERNE
//#pragma config FOSC = INTIO67, FCMEN = OFF, PLLCFG=OFF // CONFIG1H 16Mhz
#pragma config FOSC = INTIO67, FCMEN = OFF, PLLCFG=ON // CONFIG1H 32Mhz
#else
#pragma config FOSC = HSHP, PLLCFG=OFF, FCMEN=OFF
//#pragma config PRICLKEN=ON
#endif
#pragma config IESO=OFF,PWRTEN=OFF,BOREN=OFF,WDTEN=OFF,CCP2MX=PORTC1
#pragma config PBADEN=OFF,CCP3MX=PORTE0,T3CMX=PORTC0,P2BMX=PORTC0
#pragma config MCLRE=EXTMCLR,STVREN=OFF,LVP=ON,XINST=OFF,DEBUG=OFF
#pragma config CP0 = OFF, CP1 = OFF, CP2 = OFF, CP3 = OFF // CONFIG5L
#pragma config CPB = OFF, CPD = OFF // CONFIG5H
#pragma config WRT0 = OFF, WRT1 = OFF, WRT2 = OFF, WRT3 = OFF // CONFIG6L
#pragma config WRTB = OFF, WRTC = OFF, WRTD = OFF // CONFIG6H
#pragma config EBTR0 = OFF, EBTR1 = OFF, EBTR2 = OFF, EBTR3 = OFF // CONFIG7L
#pragma config EBTRB = OFF // CONFIG7H
void Init_UART1(void)
{
// USART_BRGH_HIGH,6 @ 1MHZ
// USART_BRGH_HIGH,32 @ 10MHZ
// USART_BRGH_HIGH,51 @ 16MHZ
// USART_BRGH_HIGH,25 @ 8MHZ
// init 19200Bd a 10Mhz avec IT en rx
// init 38400Bd a 20Mhz
// voir para 18.5 spec sheet DS41159B page 186
/*
#ifdef OSCILLATEUR_INTERNE
OSCCON=0b01110000; //HFINTOSC – (16 MHz)
//111 = HFINTOSC – (16 MHz)
//110 = HFINTOSC/2 – (8 MHz)
//101 = HFINTOSC/4 – (4 MHz)
//100 = HFINTOSC/8 – (2 MHz)
//011 = HFINTOSC/16 – (1 MHz)(3)
#endif
*/
Open1USART( USART_TX_INT_OFF &
USART_RX_INT_ON &
USART_ASYNCH_MODE &
USART_EIGHT_BIT &
USART_CONT_RX &
USART_BRGH_HIGH,104 ); // FOSC= 8x4=32Mhz 19200bds
}
void main()
{
i1=0;
i2=0;
Drapeaux.Fill=1;
Drapeaux.Blc=1;
DataReady1 = 0;
DataReady2 = 0;
c1=0;
c2=0;
Init_Hardware();
SortieRC2=1; // eteint la led tiree au +5V
Led_Rouge=0;
#ifdef OSCILLATEUR_INTERNE
// the internal oscillator is set to the default frequency of 1 MHz.
// The Internal Oscillator Frequency Select bits (IRCF<2:0>)
// select the frequency output of the internal oscillator block
// pour conserver 19200 bauds à 16Mhz sinon retombe à 1200 bauds
// OSCCON=0b01110000; //HFINTOSC – (16 MHz)
// OSCCONbits.IRCF2=1; //HFINTOSC – (16 MHz)
// OSCCONbits.IRCF1=1;
// OSCCONbits.IRCF0=1;
OSCCON=0b01100000; //HFINTOSC – (8 MHz)
//OSCCON=0b01010000; //HFINTOSC – (4 MHz)
//111 = HFINTOSC – (16 MHz)
//110 = HFINTOSC/2 – (8 MHz)
//101 = HFINTOSC/4 – (4 MHz)
//100 = HFINTOSC/8 – (2 MHz)
//011 = HFINTOSC/16 – (1 MHz)(3)
OSCTUNE=0;
// OSCTUNEbits.PLLEN=0; // 0 =sans PLL => 16Mhz ou 8, 4, 2, 1Mhz
OSCTUNEbits.PLLEN=1; // 1= avec PLL => 8*4= 32Mhz
#endif
Tempo(200000L);
Led_Rouge=!Led_Rouge;
OUT_RS232
c1 = 0;
DataReady1 = 0;
buffer[0]=0;
Init_UART1(); // 19200 bds
RCSTA1bits.CREN = 0 ; // disable reception
Put_RS(CLS);
Tempo(300000);
txt=&Texte[0];
strcpypgm2ram(txt,RS_Str[1]);
k=PutStr_RS(txt);
...