I have a problem with the K66. When I connected the J_LINK debuger, the LPUART doesn`t work.
Hello j_cfernandez
Are you using the LPUART0 at PTA0~PTA3? These pins are default as JTAG function.
If so, why not use other LPUART0 pins, for example:PTE8~PTE11 or PTD8~PTD11.
Best Regards
Robin
Dear,
I use the PTE8~PTE11 mit LPUART.
Did someone has a simple Init Example?
Regards
Hi
You can refer the demo when download the KSDK of FRDM-K66F:
Kinetis SDK v2 & v1.3 (REV 2.0) NewSoftware Development Kit for Kinetis MCUs, Online SDK Builder
| Download |
Best Regard
Robin
Dear,
the LPUART0 doesn't work. StatusFlags indicate sended, but there is no Datastream on the Pins
Regards.
My ini:
[...]
PORTD->PCR[8] = (0x00000500); /* RX5 */
PORTD->PCR[9] = (0x00000500); /* TX5 */
[...]
SIM->SCGC2 &= ~(SIM_SCGC2_LPUART0_MASK); /* Disable the clock to the selected UART */
SIM->SOPT2 |= SIM_SOPT2_LPUARTSRC(3); /* Selected clock Source */
SIM->SCGC2 |= SIM_SCGC2_LPUART0_MASK; /* Enable the clock to the selected UART */
/* Make sure that the transmitter and receiver are disabled while we change settings */
LPUART0->CTRL &= ~(LPUART_CTRL_TE_MASK | LPUART_CTRL_RE_MASK );
baudDiff = baud;
osr = 0;
sbr = 0;
for (osrTemp = 4; osrTemp <= 32; osrTemp++)
{
/* calculate the temporary sbr value */
sbrTemp = (sysclk / ( baud * osrTemp));
/*set sbrTemp to 1 if the sourceClockInHz can not satisfy the desired baud rate*/
if (sbrTemp == 0)
{
sbrTemp = 1;
}
/* Calculate the baud rate based on the temporary OSR and SBR values */
calculatedBaud = (sysclk / (osrTemp * sbrTemp));
tempDiff = calculatedBaud - baud;
/* Select the better value between srb and (sbr + 1) */
if (tempDiff > (baud - (sysclk / (osrTemp * (sbrTemp + 1)))))
{
tempDiff = baud - (sysclk / (osrTemp * (sbrTemp + 1)));
sbrTemp++;
}
if (tempDiff <= baudDiff)
{
baudDiff = tempDiff;
osr = osrTemp; /* update and store the best OSR value calculated */
sbr = sbrTemp; /* update store the best SBR value calculated */
}
}
/* Check to see if actual baud rate is within 3% of desired baud rate
* based on the best calculate OSR value */
if (baudDiff < ((baud / 100) * 3))
{
temp = LPUART0->BAUD;
/* Acceptable baud rate, check if OSR is between 4x and 7x oversampling.
* If so, then "BOTHEDGE" sampling must be turned on */
if ((osr > 3) && (osr < 8))
{
temp |= LPUART_BAUD_BOTHEDGE_MASK;
}
/* program the osr value (bit value is one less than actual value) */
temp &= ~LPUART_BAUD_OSR_MASK;
temp |= LPUART_BAUD_OSR(osr - 1);
/* write the sbr value to the BAUD registers */
temp &= ~LPUART_BAUD_SBR_MASK;
LPUART0->BAUD = temp | LPUART_BAUD_SBR(sbr);
}
/* Set bit count and parity mode. */
LPUART0->BAUD &= ~LPUART_BAUD_M10_MASK;
temp = LPUART0->CTRL;
temp &= ~(LPUART_CTRL_PE_MASK | LPUART_CTRL_PT_MASK | LPUART_CTRL_M_MASK);
temp &= ~(LPUART_CTRL_M_MASK|LPUART_CTRL_PE_MASK);
LPUART0->CTRL = temp;
/* set stop bit per char */
temp = LPUART0->BAUD & ~LPUART_BAUD_SBNS_MASK;
LPUART0->BAUD = temp;
/* Clear all status flags */
temp = (LPUART_STAT_LBKDIF_MASK | LPUART_STAT_RXEDGIF_MASK | LPUART_STAT_OR_MASK | LPUART_STAT_NF_MASK |LPUART_STAT_FE_MASK | LPUART_STAT_PF_MASK);
LPUART0->STAT |= temp;
temp = LPUART0->CTRL;
temp |= LPUART_CTRL_TE_MASK;
temp |= LPUART_CTRL_RE_MASK;
LPUART0->CTRL = temp;
}
Hi
If you are using the FRDM-K66F evaluation board, you can download the Kinetis SDK v2 & v1.3 (REV 2.0).
Then select and download the "SDK_2.0_FRDM-K66F" .
You can find the LPUART driver_examples after installed it, such as in "E:\SDK_2.0_FRDM-K66F\boards\frdmk66f\driver_examples\lpuart".
These driver_examples using the PTE8 and PTE9 as the LPUART0 pins.(See the BOARD_InitPins function)
You can have a test first and then change these Pins.
Robin