cancel
Showing results for 
Search instead for 
Did you mean: 

No reply form CR95HF over UART interface.

MLill.1
Associate II

We have designed a motherboard based on the NXP imx8 processor family running linux, and added the CR95HF chip on board connected to MCU over UART interface.

We have been successful in sending data in the form of 0x00 (LOW level pulse on IRQ_IN/RX), wait for 110ms and then send echo 0x55, measured on ocilloscope, however we have not yet received any data back from the chip, eg. no response.

See code and schematics below. Our main code just runs cr95fh_init() then cr95hf_idn() once before terminating.

#include "cr95hf.h"
 
int cr95hf_init(void) {
  printf("Before open\n");
  fd = open(CR95HF_PORT, O_RDWR | O_NOCTTY | O_SYNC);
  printf("After open\n");
  if(fd < 0) {
    printf("Could not open %s\n", CR95HF_PORT);
    return -1;
  }
  return CR95HF_SET_INTERFACE(B57600);
}
 
int CR95HF_SET_INTERFACE(int speed) {
  printf("Setting interface\n");
  struct termios tty;
  if(tcgetattr(fd, &tty)) {
    printf("Error from tcgetattr: %s\n", strerror(errno));
    return -1;
  }
  
  printf("Setting baud speed\n");
  //Set baud
  cfsetospeed(&tty, (speed_t)speed);
  cfsetispeed(&tty, (speed_t)speed);
 
  printf("Setting c flags\n");
  // Flags
  tty.c_cflag |= (CLOCAL | CREAD);
  tty.c_cflag &= ~CSIZE;
  tty.c_cflag |= CS8;
  tty.c_cflag &= ~PARENB;
  tty.c_cflag &= ~CSTOPB;
  tty.c_cflag &= ~CRTSCTS;
 
  printf("Setting l flags\n");
  tty.c_lflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
  tty.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
 
  printf("Setting cc flags\n");
  tty.c_cc[VMIN] = 1;
  tty.c_cc[VTIME] = 1;
 
  if(tcsetattr(fd, TCSANOW, &tty) != 0) {
    printf("Error from tcsetattr: %s\n", strerror(errno));
    return -1;
  }
 
  printf("Port is open..\n");
  usleep(10000);
  unsigned char start[] = {0x00};
  wlen = write(fd, start, sizeof(start));
  usleep(110000);
  
  return 0;
}
 
void cr95hf_idn(void) {
    unsigned char snd1[] = {0x55};
    printf("Sending...\n");
    wlen = write(fd, snd1, sizeof(snd1));
    usleep(2000);
  close(fd);
}

0693W000002lf5YQAQ.png

1 ACCEPTED SOLUTION

Accepted Solutions
Brian TIDAL
ST Employee

Hi,

this looks like an electrical issue.

I would suggest to use the X-NUCLEO-NFC03A1 as a reference platform. The pullup resistor on the UART_TX can be easily unsoldered so you can compare the voltage with the one on your board.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

6 REPLIES 6
Brian TIDAL
ST Employee

Hi,

I had a look to the schematics and have only one comment. I would recommend to connect the SPI_SS to a free IO in order to have a wake up source in case the IDLE command is used.

Can you check that the cristal is properly oscillating ? There will be no reply to the echo command in case the 27.12MHz is not present (e.g soldering issue).

Can you check the VPS and VPS_TX?

Can you provide logic analyzer traces of the UART_TX, UART_RX, SSI0, SSI1 (should be 0) at startup?

Can you try to connect your MCU UART to an X-NUCLEO-NFC03A1 board and verify that the MCU can properly communicate with the CR95HF on the X-NUCLEO-NFC03A1?

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hello Brian,

Thank you for quick response.

There was indeed an assembly error regarding the crystal (wrong orientation)😅

I now get echo response back, which is fantastic.

The only question remaining is that the UART_TX signal is at 2.5VDC. I guess this is due to its weak internal pullup. I will test to see if the MCU interprets the signal properly, but I would like to hear your thought on this. Would you recommend adding an additional pullup resistor to 3v3 on this signal?

All the best,

Marius

Brian TIDAL
ST Employee

Hi Marius,

I would recommend to follow the X-NUCLEO-NFC03A1 design where both UART_TX and UART_RX have a 3.3kOhm pullup to 3.3V (see R12 and R13 in the schematics from the User Manual UM1799 p12/17). I would also recommend to connect the SPI_CLK/MOSI/MISO/SS in case you decide to move to SPI communication (the SS pin is also used as a wake up source for the Idle command when UART is used) and to have a flexible way to configure the SSI_0 pin. Just for my information, why is the UART communication preferred in your design (most of CR95HF customer use SPI communication) ?

For the software part, I would recommend to port the X-CUBE-NFC3 firmware onto your MCU.

Rgds

Bruno

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Dear Brian,

Thank you for the input. I will connect SS pin and use pullup on both UART signals.

Reasons for choosing UART:

  • Our PCB designer had used this design previously using UART, and it fit our needs, so less time spent redesigning
  • We also already have an app developed on another platform using a RFID chip with communication over UART, so a lot of the required code can be reused, when now porting app to our new system.

Thank you for the SW recommendation, we are by the way running Linux Debian OS, so we will see how much of the SW we can make use of:)

MLill.1
Associate II

Hello Brian!

After testing the same fix on another sample of our board, I got a different behaviour. The UART_TX signal on this board is 0.7V instead of the expected 2.5V (This is without pullup resistor).

At first I expected there to be a low resistance path from TX to ground or similar, but measuring resistance from TX to gnd yields the same result on both cards 5.5k without power connected and 15+Mohm when powered on.

VPS and VPS_TX are also OK.

Crystal seems ok (at least there is no short, but I don't have the equipment to measure the crystal frequency). This could be the culprit, but I do not know if this could cause 0.7VDC on TX.

We tried connecting a pullup on TX, this made it 3.3V but still no response.

Is the appearance of 0.7VDS on TX due to chip state (IDLE or similar)? or do you expect an electrical error somewhere?

Regards,

Marius

Brian TIDAL
ST Employee

Hi,

this looks like an electrical issue.

I would suggest to use the X-NUCLEO-NFC03A1 as a reference platform. The pullup resistor on the UART_TX can be easily unsoldered so you can compare the voltage with the one on your board.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.