This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

ADE7953 communication problem?

I tried to play with nrf52840 and ade7953 .

At the begining, I use PC uart application to do the following test and everything works well.
Here are the testing steps:
1. Send 0x35 0x01 0x02 to ADE7953 and the application gets response value 0x8004 correctly.
2. Try the power-up procedure by writing 0xAD to Register Address 0xFE and writing 0x30 to Register Address 0x120 with commands:
0xCA 0x00 0xFE 0xAD 0x00
0xCA 0x01 0x20 0x30 0x00
3. Send 0x35 0x01 0x20 and get 0x30 0x00.

The test looked good, but when I tried to connect Nordic nrf52840 and ADE7953 by uart with the same tests,
the step 3 failed. I Send 0x35 0x01 0x20 and get 0x00. I connect nrf52840DK and ADE7953 by UART with pins 0.08(RX) and 0.06 (TX).
Can anyone help? Here are my test code

void meter_init() {  
  static uint8_t dataArray[6] = {0xCA, 0x00, 0xFE, 0xAD, 0x00, 0x00};
  ret_code_t err_code;

  // Write 0xAD to Register Address 0xFE:This unlocks Register 0x120
  for (uint32_t i = 0; i < 5; i++) {
    do {
      err_code = app_uart_put(dataArray[i]);
      if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_BUSY)) {
        NRF_LOG_ERROR("Failed sync to apm. Error 0x%x. ", err_code);
        APP_ERROR_CHECK(err_code);
      }
    } while (err_code == NRF_ERROR_BUSY);
  }
  nrf_delay_ms(10);

  // Write 0x30 to Register Address 0x120: This configures the optimum settings
  dataArray[0] = 0xCA;
  dataArray[1] = 0x01;
  dataArray[2] = 0x20;
  dataArray[3] = 0x30;
  dataArray[4] = 0x00;
  for (uint32_t i = 0; i < 5; i++) {
    do {
      err_code = app_uart_put(dataArray[i]);
      if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_BUSY)) {
        NRF_LOG_ERROR("Failed sync to apm. Error 0x%x. ", err_code);
        APP_ERROR_CHECK(err_code);
      }
    } while (err_code == NRF_ERROR_BUSY);
  }
  nrf_delay_ms(10);
}

  • Unfortunately, there is no stop bits can be set in the app_uart_comm_params_t. That's why I use low-level hardware register instead of setting Nordic drivers.

    Here is the definition of app_uart_comm_params_t

    /**@brief UART communication structure holding configuration settings for the peripheral.
    */
    typedef struct
    {
    uint32_t rx_pin_no; /**< RX pin number. */
    uint32_t tx_pin_no; /**< TX pin number. */
    uint32_t rts_pin_no; /**< RTS pin number, only used if flow control is enabled. */
    uint32_t cts_pin_no; /**< CTS pin number, only used if flow control is enabled. */
    app_uart_flow_control_t flow_control; /**< Flow control setting, if flow control is used, the system will use low power UART mode, based on CTS signal. */
    bool use_parity; /**< Even parity if TRUE, no parity if FALSE. */
    uint32_t baud_rate; /**< Baud rate configuration. */
    } app_uart_comm_params_t;

Related