GPIO pin definition purpose for efr32fg14

Thread Starter

yef smith

Joined Aug 2, 2020
240
Hello,I have many types of gpio as shown bellow,for my SPI i used gpioModePushPull and gpioModeInput.
And SPI shown me no transmission signal because i didnt put pullup ressistors to the output of gpioModePushPull .
How can i know for what purpose to use what GPIO type?
Thanks.


Wired-or output
Wired-or output with pull-down
Open-drain output
Open-drain output with filter.
Open-drain output with pull-up
Open-drain output using alternate control
 

Thread Starter

yef smith

Joined Aug 2, 2020
240
Hello, I want to create a 4 byte SPI transmition,so i need my Chip select to be manual.
My Chip Select is PC9 as shown in the photo bellow from the starter kit manual.
I have connected my scope to Chip select and CLK.
At first as you can see bellow that When i have AUTO CS the SPI picture is fine.
But when i made autoCsEnable false, And i tried to do manual GPIO controlling of PC9 ,it didnt allow me that.
I even could not make PC9 to be VDD,and the most amazing thing is that i have built before almost identical code for EFM32 and it worked fine.I think its because of no pullups or something critical was disables with the disabling of the pin perhaps?
Where did i go wrong?
Thanks.

https://www.silabs.com/documents/public/user-guides/ug318-brd4257b-user-guide.pdf
1610723879296.png
1610723912912.png

1610724033776.png


Code:
#include "em_device.h"

#include "em_chip.h"

#include "em_cmu.h"

#include "em_gpio.h"

#include "em_usart.h"



#define TX_BUFFER_SIZE   4

#define RX_BUFFER_SIZE   TX_BUFFER_SIZE



uint8_t com1[TX_BUFFER_SIZE] = {0x03,0x0F,0xFF,0xF0};





uint8_t RxBuffer[RX_BUFFER_SIZE];



/**************************************************************************//**

* @brief Initialize USART1

*****************************************************************************/

void initUSART1 (void)

{

  CMU_ClockEnable(cmuClock_GPIO, true);

  CMU_ClockEnable(cmuClock_USART1, true);



  // Configure GPIO mode

  GPIO_PinModeSet(gpioPortC, 8, gpioModePushPull, 0); // US1_CLK is push pull

  GPIO_PinModeSet(gpioPortC, 9, gpioModePushPull, 1); // US1_CS is push pull

  GPIO_PinModeSet(gpioPortC, 6, gpioModePushPull, 1); // US1_TX (MOSI) is push pull

  GPIO_PinModeSet(gpioPortC, 7, gpioModeInput, 1);    // US1_RX (MISO) is input

// GPIO_PinModeSet(gpioPortA, 0, gpioModePushPull, 1); //delay





  // Start with default config, then modify as necessary

  USART_InitSync_TypeDef config = USART_INITSYNC_DEFAULT;

  config.master       = true;            // master mode

  config.baudrate     = 1000000;         // CLK freq is 1 MHz

  config.autoCsEnable = false;            // CS pin controlled by hardware, not firmware

  config.clockMode    = usartClockMode1; // clock idle low, sample on rising/first edge

  config.msbf         = true;            // send MSB first

  config.enable       = usartDisable;    // Make sure to keep USART disabled until it's all set up

  USART_InitSync(USART1, &config);



  // Set USART pin locations

  USART1->ROUTELOC0 = (USART_ROUTELOC0_CLKLOC_LOC11) | // US1_CLK       on location 11 = PC8 per datasheet section 6.4 = EXP Header pin 8

                      (USART_ROUTELOC0_CSLOC_LOC11)  | // US1_CS        on location 11 = PC9 per datasheet section 6.4 = EXP Header pin 10

                      (USART_ROUTELOC0_TXLOC_LOC11)  | // US1_TX (MOSI) on location 11 = PC6 per datasheet section 6.4 = EXP Header pin 4

                      (USART_ROUTELOC0_RXLOC_LOC11);   // US1_RX (MISO) on location 11 = PC7 per datasheet section 6.4 = EXP Header pin 6



  // Enable USART pins

  USART1->ROUTEPEN = USART_ROUTEPEN_CLKPEN | USART_ROUTEPEN_CSPEN | USART_ROUTEPEN_TXPEN | USART_ROUTEPEN_RXPEN;



  // Enable USART1

  USART_Enable(USART1, usartEnable);

}



/**************************************************************************//**

* @brief Main function

*****************************************************************************/

int main(void)

{

  uint32_t i;



  // Initialize chip

  CHIP_Init();



  // Initialize USART1 as SPI slave

  initUSART1();

  GPIO_PinOutSet(gpioPortC,9);

  for(i=0;i<115;i++)//delay loop for making stable PC9

              {

               GPIO_PinOutSet(gpioPortA,5);

               GPIO_PinOutClear(gpioPortA,5);

               }

  while(1)

  {

     GPIO_PinOutClear(gpioPortC,9);

              USART_SpiTransfer(USART1,com1[0]);

              USART_SpiTransfer(USART1,com1[1]);

              USART_SpiTransfer(USART1,com1[2]);

              USART_SpiTransfer(USART1,com1[3]);

           GPIO_PinOutSet(gpioPortC,9);

            for(i=0;i<115;i++)//delay loop for making stable PC9

            {

              GPIO_PinOutSet(gpioPortA,5);

              GPIO_PinOutClear(gpioPortA,5);

             }

  }

}
 

MrChips

Joined Oct 2, 2009
23,528
Firstly, you need to understand what is meant by open-drain (also open-collector) output and why you would want this configuration.

Open drain means that the drain pin of the output MOSFET transistor is not committed, i.e. there is no load connected to the drain. It is up to the hardware designer to provide a load resistor to VDD at the drain pin.

Why would you want to do this? You can do this if the load voltage differs from VDD of the chip. You may also want to do this if two or more outputs are wired together to create a wired-OR logic function using NEGATIVE LOGIC.

Now for your specific situation, if the GPIO pin is configured as SPI alternate function then presumably the hardware is automatically configured for PUSH-PULL output. In other words, no external pull-up resistor is required.

If you are going to manually control SPI CS then you have three options:

1) configure GPIO pin with PUSH-PULL output
2) configure GPIO pin with internal PULL-UP
3) use external PULL-UP resistor
 
Top