Bare metal UART Port Initialization Problem on TWR-K70

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

Bare metal UART Port Initialization Problem on TWR-K70

跳至解决方案
1,947 次查看
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.

标签 (1)
0 项奖励
回复
1 解答
1,760 次查看
mjbcswitzerland
Specialist V

Hi

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

Regards

Mark

在原帖中查看解决方案

4 回复数
1,760 次查看
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,760 次查看
hasanoksak
Contributor II

Thanks Robin_Shen ,

Now it work,

0 项奖励
回复
1,761 次查看
mjbcswitzerland
Specialist V

Hi

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

Regards

Mark

1,760 次查看
hasanoksak
Contributor II

Hi Mark Butcher,

It worked when the clock is enabled,

Thanks,

0 项奖励
回复