Finally_Joe
Member
Hello.
I am trying to use the alternate UART0 / hardware Serial1 pins based on the LC KL26 datasheet. Can anyone tell me if this is even the correct way to use these?
Next, I am trying to receive 20 bytes in my main loop which is very short. I choose when to send the 20 bytes and the data is garbled every time.
If I send the same 20 bytes, a few seconds apart, it's different every time. I have to use these pins because it's on PCB.
But I suppose I need to make sure that I'm using the Serial1 alternate pins properly, before moving on to receiving.
Any help would be super excellent.
I am trying to use the alternate UART0 / hardware Serial1 pins based on the LC KL26 datasheet. Can anyone tell me if this is even the correct way to use these?
Code:
Serial1.begin(57600,SERIAL_8N1);
// Disable default pins
CORE_PIN0_CONFIG = 0;
CORE_PIN1_CONFIG = 0;
//TX - Alt4 usage UART0_TX
CORE_PIN24_CONFIG = PORT_PCR_DSE | PORT_PCR_SRE | PORT_PCR_MUX(4); //LC pin 24 /KL26 Pin 7 aka PTE20
//RX - Alt4 usage UART0_RX
CORE_PIN25_CONFIG = PORT_PCR_PE | PORT_PCR_PS | PORT_PCR_PFE | PORT_PCR_MUX(4); //LC pin 25 /KL26 Pin 8 aka PTE21
Next, I am trying to receive 20 bytes in my main loop which is very short. I choose when to send the 20 bytes and the data is garbled every time.
If I send the same 20 bytes, a few seconds apart, it's different every time. I have to use these pins because it's on PCB.
But I suppose I need to make sure that I'm using the Serial1 alternate pins properly, before moving on to receiving.
Code:
if(Serial1.available()>=20) { //wait until Rx buffer hits 20 bytes - (8 data bit bytes)
for (int b=0; b<20; b++)
{
myBuffer[b] = Serial1.read();
}
}
Any help would be super excellent.