Bare metal UART Port Initialization Problem on TWR-K70

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Bare metal UART Port Initialization Problem on TWR-K70

ソリューションへジャンプ
1,944件の閲覧回数
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,757件の閲覧回数
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,757件の閲覧回数
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,757件の閲覧回数
hasanoksak
Contributor II

Thanks Robin_Shen ,

Now it work,

0 件の賞賛
返信
1,758件の閲覧回数
mjbcswitzerland
Specialist V

Hi

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

Regards

Mark

1,757件の閲覧回数
hasanoksak
Contributor II

Hi Mark Butcher,

It worked when the clock is enabled,

Thanks,

0 件の賞賛
返信