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

    Are you using an nRF52840 DK or a custom board? If you're using the DK, keep in mind that P0.06 and P0.08 are routed directly to the interface MCU. The UART pins connected to the interface MCU are tri-stated when no terminal i connected to the virtual COM port on the computer. Also, what UART instance are you using for this communication? Are you sure that P0.06 and P0.08 are configured as the UART pins correctly in your project?

    Best regards,

    Simon

  • I tried to use both nRF52840 DK and a custom board, and the situation is the same. I tried to add more delays about 1.5 seconds between commands, and it works. Maybe I did something wrong in configuring UART.

    static void uart_init(void) {
      uint32_t err_code;
      app_uart_comm_params_t const comm_params =
      {
        .rx_pin_no = RX_PIN_NUMBER,
        .tx_pin_no = TX_PIN_NUMBER,
        .rts_pin_no = RTS_PIN_NUMBER,
        .cts_pin_no = CTS_PIN_NUMBER,
        .flow_control = APP_UART_FLOW_CONTROL_DISABLED,
        .use_parity = false,
    #if defined(UART_PRESENT)
        .baud_rate = NRF_UART_BAUDRATE_4800
    #else
        .baud_rate = NRF_UARTE_BAUDRATE_115200
    #endif
      };
    
      APP_UART_FIFO_INIT(&comm_params,
          UART_RX_BUF_SIZE,
          UART_TX_BUF_SIZE,
          uart_event_handle,
          APP_IRQ_PRIORITY_LOWEST,
          err_code);
      APP_ERROR_CHECK(err_code);
    
      // setup uart to 2 stop bits
      NRF_UARTE0->CONFIG = UART_CONFIG_STOP_Two << UART_CONFIG_STOP_Pos;
    }

    Best regards,

    nordicxup

Reply
  • I tried to use both nRF52840 DK and a custom board, and the situation is the same. I tried to add more delays about 1.5 seconds between commands, and it works. Maybe I did something wrong in configuring UART.

    static void uart_init(void) {
      uint32_t err_code;
      app_uart_comm_params_t const comm_params =
      {
        .rx_pin_no = RX_PIN_NUMBER,
        .tx_pin_no = TX_PIN_NUMBER,
        .rts_pin_no = RTS_PIN_NUMBER,
        .cts_pin_no = CTS_PIN_NUMBER,
        .flow_control = APP_UART_FLOW_CONTROL_DISABLED,
        .use_parity = false,
    #if defined(UART_PRESENT)
        .baud_rate = NRF_UART_BAUDRATE_4800
    #else
        .baud_rate = NRF_UARTE_BAUDRATE_115200
    #endif
      };
    
      APP_UART_FIFO_INIT(&comm_params,
          UART_RX_BUF_SIZE,
          UART_TX_BUF_SIZE,
          uart_event_handle,
          APP_IRQ_PRIORITY_LOWEST,
          err_code);
      APP_ERROR_CHECK(err_code);
    
      // setup uart to 2 stop bits
      NRF_UARTE0->CONFIG = UART_CONFIG_STOP_Two << UART_CONFIG_STOP_Pos;
    }

    Best regards,

    nordicxup

Children
No Data
Related