Remapping uart port on k64f example

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Remapping uart port on k64f example

1,447 次查看
Neo_
Contributor I

Hello, i have tested the freertos uart example from the mcuxpresso sdk for the k64f card with keil studio.

Now id like to remapp the tx rx pins so i can use uart with a rs232 adapter on the card if that's even possible. So my question is where do i remapp the pins because i cant seem to find it in the example 

 

标签 (1)
0 项奖励
回复
2 回复数

1,425 次查看
DanielRuvalcaba
NXP TechSupport
NXP TechSupport

Hello,

Please, take a look to the K64 reference manual. In section 10.3.1 you’ll find all the signals available for each pin.

Here you can download it: https://www.nxp.com/webapp/sps/download/preDownload.jsp?render=true

Now, to change the configuration of the UART example directly in the code, you will need to follow the next steps:

  1. In the project explorer, find the folder called Board
  2. Inside this folder, open the pin_mux.c file
  3. Find the BOARD_InitPins function

In this case in particular, PTB16 is configured as ALT3, and if we look at the reference manual, it says that this configures this pin as UART0_RX, this is what you need to modify.

In other words, what you need to do is to find the pins that you would like to use, verify in the reference manual if those pins are available to work with UART and change this part of the code. Also remember to verify that the clock for the port you want to use is enabled. You can enable it by using the CLOCK_EnableClock function.

I hope this helps.

Regards, Daniel.

0 项奖励
回复

1,408 次查看
mjbcswitzerland
Specialist V

Hi

Here is how it is done in the uTasker project, which makes it easier and fool-proof (can't forget to enable clocks to the port in question and can't set the wrong MUX value). Example of K64 UART0 Tx options set with different drive characteristics:

 

_CONFIG_PERIPHERAL(A, 2,  (PA_2_UART0_TX | PORT_SRE_SLOW));            // UART0_TX on PA2 (alt. function 2) slow slew rate
_CONFIG_PERIPHERAL(B, 17, (PB_17_UART0_TX | PORT_SRE_FAST));           // UART0_TX on PB17 (alt. function 3) fast slew rate
_CONFIG_PERIPHERAL(D, 7,  (PD_7_UART0_TX | PORT_ODE | PORT_DSE_HIGH)); // UART0_TX on PD7 (alt. function 3) open drain and high drive strength
_CONFIG_PERIPHERAL(A, 14, (PA_14_UART0_TX));                           // UART0_TX on PA14 (alt. function 3) default characteristics

 


A simple macro is needed:

#define _CONFIG_PERIPHERAL(port, pin, function) POWER_UP_ATOMIC(5, PORT##port); PORT##port##_PCR##pin = function

which also generates minimum instructions.

A bit-banding power up macro is also used to apply the power in the most efficient manner (this video discusses bit-banding: https://www.youtube.com/watch?v=FZnkZ1h_EAQ)

Regards

Mark

 

0 项奖励
回复