Is it possible to change logic level on a pin, configured as input , by software. Say software chip select.
My chip - TM4C123GH6PM.
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Is it possible to change logic level on a pin, configured as input , by software. Say software chip select.
My chip - TM4C123GH6PM.
You can configure GPIO pins as inputs with a weak pull-up (logic 1) or weak pull-down (logic 0).
The code snippet below uses the driverlib APIs in gpio.c .
<<
GPIOPinTypeGPIOInput(unsigned long ulPort, unsigned char ucPins);
GPIOPadConfigSet(unsigned long ulPort,
unsigned char ucPins,
unsigned long ulStrength,
unsigned long ulPinType);
>>
For the ulPinType parameter above, use GPIO_PIN_TYPE_STD_WPU for pull-up, or GPIO_PIN_TYPE_STD_WPD for pull-down.
See the software driver library user guide for more details.
-Joel
Evgeny7 said:Is it possible to change logic level on a pin, configured as input , by software. Say software chip select.
Strange question, please be more precise on what you need to do:
An input pin logic level is dictated by external stuff so cannot be changed by software internal to processor.
changing from input to output can set level on pin but again if external logic is driving that pin a contention exist and one or both processor and external logic can be damaged.
Software chip select mean changing from input to output? so is a simple direction register write?
If the master cannot control the SS pin, then there's nothing for software to so. How would the software know that the master wants to select the slave?
Instead, you should just tie it as always selected. There are plenty of SPI communication setups with a single slave where no SS signal is used.
Agree w/both slandrum & friend Roberto - your SPI Master should properly command/control your MCU's SS pin. Strange that your SPI Master does not include such control pin. (rather suspect that it is instead, "in use" w/other SPI needs)
Any free gpio pin on your SPI Master may serve this command/control role. Be sure to assert the proper logic level and hold that level until the SPI transaction has completed. In some SPI cases you may/will need to "toggle" the MCU's SS pin - thus the "tie always" SS suggestion may yield SPI operational issues...