当使用FRDM WK 36板时,我遇到了问题。我希望每个人都能帮我解决这个问题。非常感谢您,问题是:我想使用PTC 6和PTC 7这两个接口作为UART串口,但是我不知道如何将它映射到UART函数。我希望能帮到我。
Hello,
I believe you want to change the pin mux of one pin in your device, is that correct? If that it's the case, there are different ways to do it.
You can use the config tools, the serial manager or use the function that it's already configuring those pins in the functionality you are looking for.
You can find this function in the pin_mux.c
void BOARD_InitLPUART(void) {
CLOCK_EnableClock(kCLOCK_PortC); /* Port C Clock Gate Control: Clock enabled */
PORT_SetPinMux(PORTC, PIN6_IDX, kPORT_MuxAlt4); /* PORTC6 (pin 42) is configured as LPUART0_RX */
PORTC->PCR[6] = ((PORTC->PCR[6] &
(~(PORT_PCR_SRE_MASK | PORT_PCR_ISF_MASK))) /* Mask bits to zero which are setting */
| PORT_PCR_SRE(0x00u) /* Slew Rate Enable: 0x00u */
);
PORT_SetPinMux(PORTC, PIN7_IDX, kPORT_MuxAlt4); /* PORTC7 (pin 43) is configured as LPUART0_TX */
SIM->SOPT5 = ((SIM->SOPT5 &
(~(SIM_SOPT5_LPUART0TXSRC_MASK | SIM_SOPT5_LPUART0RXSRC_MASK))) /* Mask bits to zero which are setting */
| SIM_SOPT5_LPUART0TXSRC(SOPT5_LPUART0TXSRC_LPUART_TX) /* LPUART0 Transmit Data Source Select: LPUART0_TX pin */
| SIM_SOPT5_LPUART0RXSRC(SOPT5_LPUART0RXSRC_LPUART_RX) /* LPUART0 Receive Data Source Select: LPUART_RX pin */
);
}
Regards,
Estephania
Thank you very much for answering my question, and I still have questions to ask you.
First of all, I want to rewrite PTC1, 2, 3 into the following functions, is this correct?
PORT_SetPinMux(PORTC, PIN1_IDX, kPORT_MuxAsGpio);
PORT_SetPinMux(PORTC, PIN2_IDX, kPORT_MuxAlt4); /* PORTC6 (pin 42) is configured as LPUART0_RX */
PORT_SetPinMux(PORTC, PIN3_IDX, kPORT_MuxAlt4); /* PORTC7 (pin 43) is configured as LPUART0_TX */
Thank you very much for answering my question, and I still have questions to ask you.
First of all, I want to rewrite PTC1, 2, 3 into the following functions, is this correct?
Secondly, when I use debug, I will be stuck in the startup linkserver debug. Why is this?
Thank you again
Hello,
You will need to make sure that you are using the UART instead of the semihosting when importing your project.
Once you make sure of it, please verify that you already have the clock enabled and you will need to check as well you configure the rest of the pin configurations , etc.
Regards,
Estephania
Thank you again for your help. I have encountered another problem. The serial data receiving buffer area of my serial port is not big enough. Then I didn't find any place to modify it. Can you know how to modify it?
Hello,
Are you using the Connectivity Framework ? I believe you are not, so are you sure you are freeing the buffer ? Also there are some flags you need to clean manually in order to be sure that you can receive a new transaction.
How are you cleaning those flags ?
Regards,
Estephania
Thank you for your help.
The problem I encountered was to implement uart communication between the two development boards. After I sent a string of data, another development board would return at least 40 bytes of data at a time. When I use the normal LPUART_WriteBlocking function, I send data reception. Overflow, so you can't receive all the data. So I want to solve this problem by modifying the size of the data receive buffer.
Hello,
I see that you are posting in different posts about the same questions, you already have an answer in this one, could you please check it ?
Regards,
Estephania
Okay thank you
Thank you very much for answering my question, and I still have questions to ask you.
First of all, I want to rewrite PTC1, 2, 3 into the following functions, is this correct?
PORT_SetPinMux(PORTC, PIN1_IDX, kPORT_MuxAsGpio);
PORT_SetPinMux(PORTC, PIN2_IDX, kPORT_MuxAlt4); /* PORTC6 (pin 42) is configured as LPUART0_RX */
PORT_SetPinMux(PORTC, PIN3_IDX, kPORT_MuxAlt4); /* PORTC7 (pin 43) is configured as LPUART0_TX */
Thank you very much for answering my question, and I still have questions to ask you.
First of all, I want to rewrite PTC1, 2, 3 into the following functions, is this correct?
Secondly, when I use debug, I will be stuck in the startup linkserver debug. Why is this?
Thank you again