Thanks in advance...
Code: Select all
char uart_rd;
void main(void)
{
// Setting output frequency to 140MHz
PLLFBD = 68; // PLL multiplier M=70
CLKDIV = 0x0000; // PLL prescaler N1=2, PLL postscaler N2=2
// Setring USB frequency to 48MHz
// Using primary oscillator (8MHz) with APLL
ACLKCON3 = 0xB4C1; // Use primary oscillator (8MHz), APLL prescaler N1=2, APLL postscaler N2=2
ACLKDIV3 = 0x0007; // APLL multiplier M=24
ANSELA = 0x00; // Convert all I/O pins to digital
ANSELB = 0x00;
ANSELC = 0x00;
ANSELD = 0x00;
ANSELE = 0x00;
ANSELG = 0x00;
PPS_Mapping(75, _INPUT, _U1RX);// Sets pin RP98 to be Input, and maps U1RX to it
PPS_Mapping(76, _OUTPUT, _U1TX);// Sets pin RP104 to be Output, and maps U1TX to it
UART1_Init(9600);// initialize UART1 module
Delay_ms(100);
Uart1_Write_Text("uart1 ");
while (1)
{ // Endless loop
if (UART1_Data_Ready()) { // If data is received
uart_rd = UART1_Read(); // read the received data
UART1_Write(uart_rd); // and send data via UART
}
}
}