Bare metal UART Port Initialization Problem on TWR-K70

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

Bare metal UART Port Initialization Problem on TWR-K70

Jump to solution
1,324 Views
hasanoksak
Contributor II

I started a new project with KDS with PE. I added a PE serial port(UART2) component and it worked as expected.

I start a new project without KDS with PE. In order  to cofigure Port0 pin 16 and pin 17 as Uart, I used below code.

PORTE_PCR16 = (uint32_t)((PORTE_PCR16 & (uint32_t)~(uint32_t)(PORT_PCR_ISF_MASK | PORT_PCR_MUX(0x04))) | (uint32_t)(PORT_PCR_MUX(0x03)));
PORTE_PCR17 = (uint32_t)((PORTE_PCR17 & (uint32_t)~(uint32_t)(PORT_PCR_ISF_MASK | PORT_PCR_MUX(0x04))) | (uint32_t)(PORT_PCR_MUX(0x03)));

When I debug the code with P&E Micro debugger, within these lines the progran jumps to the "Default_Handler".

I tried "PORTE_PCR16 = 0x300;" and "PORTE_PCR17 = 0x300;" as well but the result is same.

Please any commend.

Labels (1)
0 Kudos
Reply
1 Solution
1,137 Views
mjbcswitzerland
Specialist V

Hi

Enable the clock to the port in SIM_SCGC5 and then the hard fault will not occur.

Regards

Mark

View solution in original post

4 Replies
1,137 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Hasan,

If you want to use UART2 and PORTE modules, you need enable their clock gates manually first.

The PE has enabled these clock gates automatically.

See below image:

clock gate enable.jpg

Best Regards,

Robin

-----------------------------------------------------------------------------------------------------------------------

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

-----------------------------------------------------------------------------------------------------------------------

1,137 Views
hasanoksak
Contributor II

Thanks Robin_Shen ,

Now it work,

0 Kudos
Reply
1,138 Views
mjbcswitzerland
Specialist V

Hi

Enable the clock to the port in SIM_SCGC5 and then the hard fault will not occur.

Regards

Mark

1,137 Views
hasanoksak
Contributor II

Hi Mark Butcher,

It worked when the clock is enabled,

Thanks,

0 Kudos
Reply