Configure Pins in MQX Task

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

Configure Pins in MQX Task

Jump to solution
387 Views
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 Kudos
1 Solution
295 Views
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.

View solution in original post

0 Kudos
1 Reply
296 Views
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 Kudos