reception not possible in uart

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

reception not possible in uart

Jump to solution
2,761 Views
manvitha
Contributor II

Hello,

  Why does only transmission happens in UART communication (Using sample code LQRUG_uart_ex1 for KL25Z128 MCU) where data is not receiving instead it reaches to default handler function given below and suspends?

void Default_Handler()

{

__asm("bkpt");

}

can anyone please help me in this?

Labels (1)
0 Kudos
1 Solution
2,238 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Manvitha,

IAR and CW are different IDE tools , and the main difference is the compiler. So you can not directly import the source code for a IAR project into CW workspace, some definitions might be different and some might miss, To creat the CW based project, please run "make_new_cw_project.exe" in "Kinetis L Sample Code\kl25_sc_rev6\klxx-sc-baremetal\build\cw". Please kindly refer to FRDM_KL25ZSCG_CW.pdf in "Kinetis L Sample Code\kl25_sc_rev6" for more details.

can we configure two different port pins for Tx and Rx or is there any other way?

-Yes, you can do that. just remember don't enable two sets of TX and RX for the same UARTx module.

Hope that helps,

B.R

Kan

View solution in original post

0 Kudos
12 Replies
2,238 Views
Paul_Tian
NXP Employee
NXP Employee

Hi, Manvitha

I tested project from path \Kinetis L Sample Code\kl25_sc_rev6\klxx-sc-baremetal\build\iar\LQRUG_uart_ex1. It can work well. Please reference following picture. As you can see, I use HyperTerminal and press character q, then c get the value of q.

1.bmp

I think your project might not be newest one, would you please help to download and test again. And also pay attention to baudrate is 115200.

Hope my reply can help you.

Best Regards

Paul

0 Kudos
2,238 Views
manvitha
Contributor II

Hi, Zhe Tian

Even I am doing with the same code with port A 2 and port A 1

pins and given the same baudrate (#define TERMINAL_BAUD 115200) but it

is pointing to Default_Handler() (attached image 2) when it reaches printf

statement in the beginning of code(attached image 2)

I test the code in following steps

- Build the selected code

- connecting the board with pc and open the tera term with selecting

particular com port with baud 115200

- debug and run the code step by step(F6)

it will halt(suspend) pointing to default handler. can I know where my

fault is?

Thanks and Regards,

Manvitha

0 Kudos
2,238 Views
martynhunt
NXP Employee
NXP Employee

Hi Manvitha,

Could you post screen shots of your register values before you enter the Default_Handler for the following registers: SIM_SOPT2, SIM_SCGC4, UART0_BDL, UART0_C4, PORTA_PCR1 & PORTA_PCR2?

Thank you,

Martyn

0 Kudos
2,237 Views
manvitha
Contributor II

Hi Martyn,

attached is the screenshot of register initialisation(image 1). it

will enter this initialisation register(during step by step execution)

while printf statement in the beginning is disabled.(image 2)

Thanks and Regards,

Manvitha.

On Thu, May 30, 2013 at 7:46 AM, Martyn Hunt

0 Kudos
2,237 Views
Kan_Li
NXP TechSupport
NXP TechSupport

From the attachment, seems you are using the CW , but I am confused as there is no CW based LQRUG_uart_ex1 project in the latest Kinetis L Sample Code

a1.JPG

so are you referring to your custom CW project which is ported from the IAR based LQRUG_uart_ex1 project? would you please help to clarify? Thanks for your patience!!


BTW, if you are doing the porting, there is one thing to notice:

UART port is initialized in sysinit.c, for FRDM-KL25Z, PTA1 and PTA2 are used as UART0, but if the PORT_Init() in the main() configures another set of UART0 port, RX function might have problem, though TX should still be fine.


Transmit works just fine if you accidentally configure two pins for the same function, because they are both driven by the same module, but if you configure the input function on two pins then you get undefined behavior, because they are both driving the same thing.



0 Kudos
2,237 Views
manvitha
Contributor II

Hello Kan Li,

yes I referred to custom CW project which is ported from the IAR

based LQRUG_uart_ex1 project I mean to say that i just imported the code with

all source files(common, cpu, drivers, platform and sysint). from the path

*..\Kinetis L Sample

Code\kl25_sc\klxx-sc-baremetal\src\projects\LQRUG_uart_ex1** *

Is there any problem in doing that? please clear me on this.

And coming back to porting by configuring the input function on two pins we

will get undefined behavior then can we configure two different port pins

for Tx and Rx or is there any other way?

Thanks and Regards,

Manvitha.

0 Kudos
2,239 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Manvitha,

IAR and CW are different IDE tools , and the main difference is the compiler. So you can not directly import the source code for a IAR project into CW workspace, some definitions might be different and some might miss, To creat the CW based project, please run "make_new_cw_project.exe" in "Kinetis L Sample Code\kl25_sc_rev6\klxx-sc-baremetal\build\cw". Please kindly refer to FRDM_KL25ZSCG_CW.pdf in "Kinetis L Sample Code\kl25_sc_rev6" for more details.

can we configure two different port pins for Tx and Rx or is there any other way?

-Yes, you can do that. just remember don't enable two sets of TX and RX for the same UARTx module.

Hope that helps,

B.R

Kan

0 Kudos
2,237 Views
manvitha
Contributor II

Hi Kan,

I had no idea about IAR IDE compiler hope I will do good now. thank

you for the guidance.

Regards,

Manvitha.

0 Kudos
2,237 Views
martynhunt
NXP Employee
NXP Employee

Also, make sure that NO_PLL_INIT is defined. If it is, make sure that the following section in sysinit.c looks like this:

#if defined(NO_PLL_INIT)

       

        mcg_clk_hz = 21000000;

       

        SIM_SOPT2 &= ~SIM_SOPT2_PLLFLLSEL_MASK;  // clear PLLFLLSEL to select the FLL for this clock source

       

        uart0_clk_khz = (mcg_clk_hz / 1000);  // the uart0 clock frequency will equal the FLL frequency

In addition, make sure that UART0 is being re-initialized to the correct baud rate (115200). The UART0 register settings in the UART0_Init function should look like so:

UART0_BDH = 0x00;

UART0_BDL = 0x1A;

UART0_C4 = 0x06;

UART0_C1 = 0x00;

UART0_C3 = 0x00;

UART0_MA1 = 0x00;

UART0_MA1 = 0x00;

UART0_S1 |= 0x1F;

UART0_S2 |= 0xC0;

For future reference, the UART baud rate is defined as such:

/*

* baud rate = CLK / [(OSR + 1) x BR]

* Where CLK is the bus clock speed in hz,

* OSR is over sampling ratio (UARTx_C4 bits 0-4),

* and BR is baud rate modulo divisor (UARTx_BDL bits 0-7).

*/

Further explanation can be found in Chapter 39 of the KL25 Reference Manual.

http://cache.freescale.com/files/32bit/doc/ref_manual/KL25P80M48SF0RM.pdf?fpsp=1&WT_TYPE=Reference%2...

0 Kudos
2,237 Views
markosiponen
Contributor III

Why write to UART_MA1 twice?

  1. UART0_MA1 = 0x00
  2. UART0_MA1 = 0x00;

0 Kudos
2,237 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Markosiponen,

I think it should be a typo issue, and it should be like that:

  1. UART0_MA1 = 0x00;
  2. UART0_MA2 = 0x00


Please kindly let me know if you have any further question.


B.R

Kan

0 Kudos
2,237 Views
manvitha
Contributor II

Hi Martyn,

I came to know that I had imported IAR project to CW workspace.

Only with this changes will it work fine?

Thanks and Regards,

Manvitha.

On Fri, May 31, 2013 at 7:16 AM, Martyn Hunt

0 Kudos