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);
}

Parents
  • Hi

    You can try to set both baud rates to 4800, seeing as the ADE7953 operates at a fixed baud rate, and won't handle any others very well (I'd imagine). Other than that, I don't see any issues with your UART init function. Are you able to narrow down what exact delay(s) are making or breaking the application? Do you see the same issue if you try to use the nRF devices to communicate with one another at a baud rate of 4800 for example?

    The test looked good, but when I tried to connect Nordic nrf52840 and ADE7953 by uart with the same tests,

     What do you mean by that the test looked good. Were you able to make the ADE7953 communicate and run this test as intended with any other devices?

    Best regards,

    Simon

  • The default baud rates of ADE7953 is 4800. I think my UART init function of nRF52840 is correct because the ble application sends 0x35 0x01 0x02 to ADE7953 and gets response value 0x8004 correctly.

    In the ADE7953 power-up procedure, I have to unlock and set register 0x01 and 0x20 with value 0x0030. The ADE7953 datasheet indicates that there should be at least 6 ms delay between commands. So I send 2 commands sequentially with 10 ms delay. Here are the commands

    0xCA 0x00 0xFE 0xAD 0x00
    0xCA 0x01 0x20 0x30 0x00

    Then send 0x35 0x01 0x20 to read register. If ADE7953 correctly recognizes the commands, it should return 0x30 0x00, but I always get 0x00 0x00.

    I try to add more delay to 1.5 seconds between the commands, and then send 0x35 0x01 0x20 command, I get 0x30 0x00 correctly.

    I do not know why this happened, but it works.

    Best regards,

    nordicxup

     

Reply
  • The default baud rates of ADE7953 is 4800. I think my UART init function of nRF52840 is correct because the ble application sends 0x35 0x01 0x02 to ADE7953 and gets response value 0x8004 correctly.

    In the ADE7953 power-up procedure, I have to unlock and set register 0x01 and 0x20 with value 0x0030. The ADE7953 datasheet indicates that there should be at least 6 ms delay between commands. So I send 2 commands sequentially with 10 ms delay. Here are the commands

    0xCA 0x00 0xFE 0xAD 0x00
    0xCA 0x01 0x20 0x30 0x00

    Then send 0x35 0x01 0x20 to read register. If ADE7953 correctly recognizes the commands, it should return 0x30 0x00, but I always get 0x00 0x00.

    I try to add more delay to 1.5 seconds between the commands, and then send 0x35 0x01 0x20 command, I get 0x30 0x00 correctly.

    I do not know why this happened, but it works.

    Best regards,

    nordicxup

     

Children
  • "If there was a framing error (wrong stop bit), that specific byte will NOT be stored into Data RAM, but following incoming bytes will."

    Worth enabling or placing a break at the framing error case in the handler, as such an error (for whatever reason) will give the issue you observe. In passing in any case note that setting 2 stop bits via the hardware register (as in the code you posted) bypasses any Nordic driver knowledge of the setting; better (assuming it is an option) to use app_uart_comms_param_t as you do for the other settings. In general only use low-level hardware register or Nordic drivers; never mix the two without risking invoking puzzling side effects.

  • 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