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

UART with nRF52832 and FONA 808

Hello,

I am attempting to achieve UART Serial Communication with the ADAFRUIT FONA 808 Board, this has a SIM808 Cellular Modem.

I have attempted to re-purpose the examples/peripheral/uart example in SDK 14.2 to no avail. I also tried to re-purpose the BLE UART example to see if I could piggyback on something that I knew would work and instead of the communication go to the PC the communication would go to the FONA 808, however this did not work either.

//#define ENABLE_LOOPBACK_TEST  /**< if defined, then this example will be a loopback test, which means that TX should be connected to RX to get data loopback. */

#define MAX_TEST_DATA_BYTES     (15U)                /**< max number of test bytes to be used for tx and rx. */
#define UART_TX_BUF_SIZE 256                         /**< UART TX buffer size. */
#define UART_RX_BUF_SIZE 256                         /**< UART RX buffer size. */

void uart_error_handle(app_uart_evt_t * p_event)
{
    if (p_event->evt_type == APP_UART_COMMUNICATION_ERROR)
    {
        APP_ERROR_HANDLER(p_event->data.error_communication);
    }
    else if (p_event->evt_type == APP_UART_FIFO_ERROR)
    {
        APP_ERROR_HANDLER(p_event->data.error_code);
    }
}

/**
 * @brief Function for main application entry.
 */
int main(void)
{
    uint32_t err_code;
    uint8_t my_tx_buf[] = {'A','t',0xD}; // ((uint8_t)0x65),((uint8_t)0x84),((uint8_t)0x10)
    uint8_t my_rx_buf[50];
    bsp_board_leds_init();
    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    NRF_LOG_DEFAULT_BACKENDS_INIT();
    
    NRF_LOG_INFO("UART 808 example.");

    bsp_board_leds_init();

    const app_uart_comm_params_t comm_params =
      {
          RX_PIN_NUMBER,
          TX_PIN_NUMBER,
          RTS_PIN_NUMBER,
          CTS_PIN_NUMBER,
          APP_UART_FLOW_CONTROL_DISABLED,
          false,
          NRF_UART_BAUDRATE_115200
      };

    APP_UART_FIFO_INIT(&comm_params,
                         UART_RX_BUF_SIZE,
                         UART_TX_BUF_SIZE,
                         uart_error_handle,
                         APP_IRQ_PRIORITY_LOWEST,
                         err_code);

    APP_ERROR_CHECK(err_code);

    while (true)
    {
        NRF_LOG_INFO(" Running:");
        uint8_t cr;
        cr = (my_tx_buf[0]);
        //while (app_uart_put(cr) != NRF_SUCCESS)
        app_uart_put(cr);
        cr = (my_tx_buf[1]);
        app_uart_put(cr);
        cr = (my_tx_buf[2]);
        app_uart_put(cr);
        while (app_uart_get(&my_rx_buf) != NRF_SUCCESS){
          nrf_delay_ms(500);
        }
        
        NRF_LOG_HEXDUMP_INFO(my_rx_buf, strlen((const char *)my_rx_buf));
        NRF_LOG_FLUSH();
        nrf_delay_ms(900);//orig 200
        
    }

}

This is the snippet from the latest attempt using the peripheral uart example within the SDK. If someone might be able to point me in the right direction, or explain how I might better do this I would appreciate it. I was able to make SPI work for the most part with an accelerometer and it gave me a lot of confidence before this happened. Too bad I cant use SPI with this.

As far as I can tell, if I can get this going then all I need to do is be able to send ASCII text and receive data back and convert it to ASCII to read.

As a side note I couldn't get the logger working either, but this isn't my main concern.

Parents Reply Children
No Data
Related