AnsweredAssumed Answered

How to define an 8-bit parallel bidirectional databus (PD0-PD7)?

Question asked by dan on Jul 15, 2015
Latest reply on Jul 15, 2015 by dan
Hi all,

I am using a STM32F103VEH MCU which controls an external PN512 (NXP semiconductors) NFC RF reader. The MCU and PN512 communicate over a 8-bit bidirectional parallel interface as databus to exchange information between the MCU and PN512. I have written following functions which will be used to make the bus either output form MCU to send data to PN512 or input to MCU to read data from PN512:

void PN512_set_pins_input() {
  GPIO_InitTypeDef GPIO_InitStruct;

  // ---------- Setup ports for GPIOC ----------
  GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0
                           | GPIO_Pin_1
                           | GPIO_Pin_2
                           | GPIO_Pin_3
                           | GPIO_Pin_4
                           | GPIO_Pin_5
                           | GPIO_Pin_6
                           | GPIO_Pin_7;
  GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  GPIO_Init(GPIOC, &GPIO_InitStruct);
}

void PN512_set_pins_output() {
  GPIO_InitTypeDef GPIO_InitStruct;

  // ---------- Setup ports for GPIOC ----------
  GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0
                           | GPIO_Pin_1
                           | GPIO_Pin_2
                           | GPIO_Pin_3
                           | GPIO_Pin_4
                           | GPIO_Pin_5
                           | GPIO_Pin_6
                           | GPIO_Pin_7;
  GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOC, &GPIO_InitStruct);
}

I have measured the pin voltages and it seems that the output from MCU to the chip works fine when I call "PN512_set_pins_output" before sending data. Now the problem is that I cannot receive the correct data that I expect from PN512 to the MCU, after I call "PN512_set_pins_input" and the received data is always same. I am not sure whether I define the pins as input to the MCU in wrong way or I am send wrong command to PN512 chip. Is there anyone who can guide me through this problem?

Sincerely,

Dan.

Outcomes