Configure Pins in MQX Task

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

Configure Pins in MQX Task

跳至解决方案
978 次查看
adyr
Contributor V

Hi,

I have created an MQX + KSDK project for the IAR compiler using PEx. I have added an fsl_dspi component as spiCom2 and configured it and it all works well reading and writing to a 32Mbit flash memory. But in the final design the memory is used to program an FPGA at boot up so I only want the micro controller SPI pins to be programmed when the FPGA code is updated by the user and at all other times the SPI pins need to be inputs or tri-state.

I have switched off the auto-initialise option in the PinSettings component and this has satisfied the first requirement of keeping the pins disabled as configure_spi_pins is no longer called in hardware_init. However when I call configure_spi_pins from my FPGA_update task it causes the HardFault_Handler to be called as soon as PORT_HAL_SetMuxMode(PORTD_BASE,11u,kPortMuxAlt2); is called. This is the first time I have used an RTOS in an embedded design so I'm not sure why it is not working. I have checked that MQX_ENABLE_USER_MODE is set to 0 so I presume my task is priviledged enough but is there anything else I need to do?

Thanks for any assistance,
Adrian

0 项奖励
回复
1 解答
886 次查看
adyr
Contributor V

I have tracked it down. Nothing to do with MQX. It turns out that Common_Init() in Cpu.c that is generated by PEx disables the gate clocking on certain ports and "Any bus access to a peripherals that has its clock disabled generates and error termination" as stated in the reference manual.

I have modified my code in my task to enable the clock on the ports, call configure_spi_pins(HW_SPI2) and then disable the port clocks again, Now all is good again.

Adrian.

在原帖中查看解决方案

0 项奖励
回复
1 回复
887 次查看
adyr
Contributor V

I have tracked it down. Nothing to do with MQX. It turns out that Common_Init() in Cpu.c that is generated by PEx disables the gate clocking on certain ports and "Any bus access to a peripherals that has its clock disabled generates and error termination" as stated in the reference manual.

I have modified my code in my task to enable the clock on the ports, call configure_spi_pins(HW_SPI2) and then disable the port clocks again, Now all is good again.

Adrian.

0 项奖励
回复