AtomSoft
Well-Known Member
All i get is gibberish... or HIGH values like 0xE0 or higher...
Im going for a 40MHz using PLL and a 10MHz OSC... Its not a hardware problem as i had this board working before using some other code... (LOST)
So am i setting this all up ok? Any Thoughts?
Im trying for 19200bps 8-N-1
Thanks Guys/Gals
Im going for a 40MHz using PLL and a 10MHz OSC... Its not a hardware problem as i had this board working before using some other code... (LOST)
So am i setting this all up ok? Any Thoughts?
Im trying for 19200bps 8-N-1
Thanks Guys/Gals
Code:
#pragma config OSC = HSPLL, BOREN = OFF, WDT = OFF, MCLRE = OFF, LVP = OFF, XINST = ON
/******************************************************************************/
/* User Global Variable Declaration */
/******************************************************************************/
/******************************************************************************/
/* Main Program */
/******************************************************************************/
void main(void)
{
unsigned char var;
/* Configure the oscillator for the device */
ConfigureOscillator();
/* Initialize I/O and Peripherals for application */
InitApp();
/* TODO <INSERT USER APPLICATION CODE HERE> */
while(1)
{
var = getChar();
}
}
void ConfigureOscillator(void)
{
// 40MHZ - 10MHZ * 4xPLL
OSCCON = 0; //Primary OSC Selected
while(!OSCCONbits.OSTS); //Wait until Primary OSC is ready and running
ADCON0 = 0;
ADCON1 = 0x0F;
CMCON = 0x07;
}
void InitApp(void)
{
//Enable UART 19200,8-N-1
RCSTAbits.SPEN = 1;
TRISC |= 0b11000000;
SPBRG = 129;
TXSTA = 0b00100100;
BAUDCON = 0b00000000;
RCSTA = 0b10010000;
PIR1 = 0;
}
unsigned char getChar(void)
{
unsigned char rxTemp = 0;
while(PIR1bits.RCIF == 0);
rxTemp = RCREG;
return rxTemp;
}
Last edited: