We are using the flexbus of a MK24 to drive a display. When we go to sleep, we have to cut off the power to the display module. Therefore, we need to make sure all the pins that are configured as outputs to this device are disabled (or put into a high-impedance state) before we turn off the power. Is there an easy way to do this using PEx? We are using the Init_FB component in PEx 10.4 to configure these lines but it doesn't support any methods other than the Init call.
One idea I had was to simply change the PORT_PCR_MUX of these lines to 0 but I am unsure if that disables the pins when the ALT0 cell in the "Signal Multiplexing and Pin Assignments" table in the K24 Reference Manual is blank. Although this table says that the "default" setting of these pins is "disabled", it does not say that you can disable the pin by setting the PCR MUX to 0.
A second approach I have considered is to reconfigure these pins as GPIO inputs. One way to do this from PEx would be to have two sets of "Init_GPIO" components--one that configures the pins for sleep state and one that configures for the running state. Would there be any problems with having multiple Init_GPIO components defined for the same GPIO Port?
The final approach I have considered is ignoring PEx and just writing functions to configure these lines as needed. I can certainly do this but dislike the "mixed" approach (i.e. some configuration done by PEx and some by user-written code).
Any ideas, examples, suggestions, etc. will be appreciated!!
I don't know whether PE supports this but if you don't mind writing general code to access the processor's peripheral it is very efficient using the following:
GPIOA_PDDR = 0; // optional since the DDR is usually already 0
PORTA_GPCLR = ((0xffff0000) | PULL_UP_STATE | PORT_MUX_GPIO);
PORTA_GPCHR = ((0xffff0000) | PULL_UP_STATE | PORT_MUX_GPIO);
Where PULL_UP_STATE can be set to either be floating, pull-up or pull-down (check the registers for the defines to use).
This also assumes all 32 pins of a port are to be set to inputs (by controlling the masks 0xffff0000 with just the required pin bits you can set any pattern required).
If more that one port is involved the same can be done for each one (A, B, C, etc.)
This is the fastest and most efficient method since each port write acts on up to16 pins at the same time.
Users of the uTasker project do this using the macro
_CONFIG_PORT_INPUT_FAST_LOW(ref, pins, chars)
_CONFIG_PORT_INPUT_FAST_LOW(B, (PORTB_BIT6 | PORTB_BIT7 | PORTB_BIT15), PORT_PS_UP_ENABLE);
Kinetis: µTasker Kinetis support
For the complete "out-of-the-box" Kinetis experience and faster time to market
As Mark pointed out, I think it is the best way to configure the FlexBUS pin as GPIO and input mode(setting MUX bits 001 in PORTx_PCRx register, clearing the bit in GPIOx_DDR register), enable the pull-down function(by setting the PE bit and clearing the PS bit).
If you set the pin in GPIO and OUTPUT mode and in Open Drain mode, because there is not external pull-up resistor, the pin will be keep in less than 200mV, I think it is a method. If you set the pin in GPIO mode/Output mode and output Low logic, the pin will keep low in sleep mode, but it will consume energy.