AtomSoft
Well-Known Member
OK i have a setup like:
Whats my final speed? I think 48MHz but im getting gibberish from the UART... and i know i set that up correctly...
So either its the UART or the SPEED(FOSC) ... but i would like to know what speed is this supposed to run on.. Im also using USB on this with PLL active...
Code:
#pragma config PLLDIV = 2 //Divide by 2 (8 MHz oscillator input)
#pragma config CPUDIV = OSC1 //No CPU system clock divide
#pragma config OSC = INTOSCPLL //Internal Oscillator mode, RA7:6 PORT FUNCTION
#pragma config IESO = OFF //Two-Speed Start-up disabled
........
unsigned int pll_startup_counter = 600;
OSCCON = 0;
/* Setup the Internal OSC for 8 MHz*/
OSCCONbits.IRCF0 = 1;
OSCCONbits.IRCF1 = 1;
OSCCONbits.IRCF2 = 1;
/* Wait until OSC is running and stable*/
while((OSCCON & 0x0C) != 0x0C);
OSCTUNEbits.INTSRC = 1;
OSCTUNEbits.PLLEN = 1; //Enable the PLL and wait 2+ms until the PLL locks before enabling USB module
while(pll_startup_counter--);
Whats my final speed? I think 48MHz but im getting gibberish from the UART... and i know i set that up correctly...
Code:
void config_uart(void){
unsigned char config=0,spbrg=0,baudconfig=0;
/* ---PPS Configuration--- */
PPSUnLock();
iPPSInput(IN_FN_PPS_RX2DT2,IN_PIN_PPS_RP20); //Configre RP20 as RX Pin
iPPSOutput(OUT_PIN_PPS_RP17,OUT_FN_PPS_TX2CK2); //Configre RP17 as TX Pin
PPSLock();
TRISDbits.TRISD3 = 1; //RX
TRISCbits.TRISC6 = 0; //TX
Close2USART(); //turn off usart if was previously on
/* -----configure USART ----- */
config = USART_TX_INT_OFF | USART_RX_INT_OFF | USART_ASYNCH_MODE | USART_EIGHT_BIT | USART_CONT_RX | USART_BRGH_LOW;
/* -----SPBRG needs to be changed depending upon oscillator frequency------- */
spbrg = 77; //At 48Mhz of oscillator frequency & baud rate of 9600.
Open2USART(config, spbrg); //API configures USART for desired parameters
baudconfig = BAUD_8_BIT_RATE | BAUD_AUTO_OFF;
baud2USART (baudconfig);
}
So either its the UART or the SPEED(FOSC) ... but i would like to know what speed is this supposed to run on.. Im also using USB on this with PLL active...