In order to reach COM speed to 115200 for a Blue tooth serial interface, I needed to set the Oscillator source to Primary and the Primary Osc mode to FRC w/PLL 4x (fast RC 4x PLL).
to achieve the same with soft comms, HS2 was set to PLL x 16 and not FRC 4x PLL
Analogue ref on comms of 115200 via Bluetooth, all works OK
I tried to see how fast I could go with the comms, 115200 was the Max I could achieve (for now).
Code: Select all
#include <built_in.h>
unsigned adcRes;
unsigned rx1;
unsigned char uc1;
void main() {
char *txt = "mikroe";
int i=0;
int error;
ADPCFG = 0xFFFF;
TRISB = 0x0;
PORTB = 0x0000;
TRISB = 0xFFFF;
// Delay_Cyc(0,1023); // added for softcoms
// Soft_Uart_Init(&portf, 2, 3, 115200, 0); // softcoms at FRC PLL x 16
Uart1_Init(115200);
U1MODEbits.ALTIO = 1; // added to analog example
Delay_ms(500); // extended the delay
while (1) {
if (Uart1_Data_Ready()) {
rx1 = Uart1_Read_Char();
Uart1_Write_Char(rx1);
}
//**************************
// i = Soft_Uart_Read(&error);
// if (!error)
// Soft_Uart_Write(i);
// else
// Soft_Uart_Write('e'),Soft_Uart_Write(i);
//***************************
// adcRes = Adc_Read(1);
// Soft_Uart_Write(adcRes); //Uart1_Write_Char(adcRes);
// Delay_ms(5);
}
}//~!