Trouble modifiying kinetis bootloader to UART2 on KL25

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Trouble modifiying kinetis bootloader to UART2 on KL25

1,260 Views
carlosglez
Contributor I

Hi! 
  

  I download the Kinetis Bootloader 2.0.0 and try with the default pins and configuration (UART0) and it works. Now I want to modify to UART2 but have some troubles with it. Once I download my code to the board, I can´t connect with the board with the Kinetis Flash Tool. 

  I already change some variables of the code to use UART2 but still not working. 

   When initializing the default UART0 theres a line as follow:

SIM->SOPT2 = SIM_SOPT2_PLLFLLSEL_MASK // set PLLFLLSEL to select the PLL for this clock source
                        | SIM_SOPT2_UART0SRC(1); // select the PLLFLLCLK as UART0 clock source

But theres not SRC for UART2, does this affect? I initialize my UART2 clock as following  SIM->SCGC4 |= SIM_SCGC4_UART2_MASK;

 The question is: Is it posible to use bootloader with UART2? in case of yes, any idea of what can I be missing?

Thanks!!

CarlosG.

Labels (1)
0 Kudos
7 Replies

866 Views
merigotbertrand
Contributor III

I forgot,

I changed nothing in the kinetisflashtools.

regards

bertrand

0 Kudos

866 Views
merigotbertrand
Contributor III

Hello carlos.

I just finish a bootloader on a kinetis KV46,

Some files need to be modified in order to activate your IO

On my side I changed :

Hardware_init_Kxx.C files

(get_uart_clock) check if your uart is in the list

Peripherals_Kxx.C files

(const peripheral_descriptor_t g_peripherals array) check the instance value

Peripheral_pinmux.h

(peripheral enable configuration) check if BL_ENABLE_PINMUX is correct

(UART pinmux configurations) check your configuration and adapt it to the port you want to use

#define UART2_RX_PORT_BASE
#define UART2_RX_GPIO_BASE
#define UART2_RX_GPIO_PIN_NUM
#define UART2_RX_FUNC_ALT_MODE
#define UART2_RX_GPIO_ALT_MODE
#define UART2_RX_GPIO_IRQn
#define UART2_RX_GPIO_IRQHandler
#define UART2_TX_PORT_BASE
#define UART2_TX_GPIO_PIN_NUM
#define UART2_TX_FUNC_ALT_MODE

Now my kinetis bootloader is running well with autobaud 256Kb/sec but the way long

regards

Bertrand

0 Kudos

866 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi CarlosG,

    UART1 and UART2 modules operate from the bus clock, so you just need to use the bus clock. You don't need to care about:

SIM->SOPT2 = SIM_SOPT2_PLLFLLSEL_MASK // set PLLFLLSEL to select the PLL for this clock source
                        | SIM_SOPT2_UART0SRC(1); // select the PLLFLLCLK as UART0 clock source

You need to modify peripherals_pinmux.h, modify the UART0 to UART2, and use the UART2 pin. Peripherals_MKL25Z4.c also need to modify the g_peripherals to UART2 interface.

Please try it on your side.

Wish it helps you!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

866 Views
carlosglez
Contributor I

Hi Kerry!

    Thanks for your soon answer. I actually change those files but still not working. Anything else? I read on the KL25 reference manual that UART2 has not autobaudrate. So I also change that and set a static baudrate but can't connect with the tool.

     Any idea?

CarlosG.

0 Kudos

866 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Carlos Gonzalez,

  Please tell me which UART2 pin you want to use, I will try it on my side, then tell you the details.

Have a great day,
Kerry

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

866 Views
carlosglez
Contributor I

Hi Kerry, 


   I'm using the UART2 pin D2 and D3. Thanks for your help!

CarlosG. 

0 Kudos

866 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Carlos,

   Do you debug your modified bootloader? After you connect with the KinetisFlashTool, where the code is stopping on your side?

Kerry

0 Kudos