Hi
I am using SDK15.2 and trying to do a loop of serial write.
The first write is ok, but all other writes fail.
This is the code I am using:
#include "nrf_serial.h"
#define d_NA 0
NRF_SERIAL_DRV_UART_CONFIG_DEF(m_uart0_drv_config,
Motor_Dir, Step_Pulse_PWM,
d_NA, d_NA,
NRF_UART_HWFC_DISABLED, NRF_UART_PARITY_EXCLUDED,
NRF_UART_BAUDRATE_115200,
UART_DEFAULT_CONFIG_IRQ_PRIORITY);
#define SERIAL_FIFO_TX_SIZE 32
#define SERIAL_FIFO_RX_SIZE 32
NRF_SERIAL_QUEUES_DEF(serial_queues, SERIAL_FIFO_TX_SIZE, SERIAL_FIFO_RX_SIZE);
#define SERIAL_BUFF_TX_SIZE 1
#define SERIAL_BUFF_RX_SIZE 1
NRF_SERIAL_BUFFERS_DEF(serial_buffs, SERIAL_BUFF_TX_SIZE, SERIAL_BUFF_RX_SIZE);
NRF_SERIAL_CONFIG_DEF(serial_config, NRF_SERIAL_MODE_IRQ,
&serial_queues, &serial_buffs, NULL, NULL);
NRF_SERIAL_UART_DEF(serial_uart, 0);
/********************* Serial port definitions **************************/
Status_Code SetSerialConnection(void)
{
ret_code_t ret;
// Free Pin 17 and Pin 19
nrf_gpio_pin_write(Step_Pulse_PWM, Disable); // Pin17 - Tx
nrf_gpio_pin_write(Motor_Dir, Disable); // Pin19 - RX
ret = nrf_serial_init(&serial_uart, &m_uart0_drv_config, &serial_config);
if (ret != NRF_SUCCESS)
{
printf("nrf_serial_init FAIL-%d\r\n", ret);
return(e_Status_Fail);
}
else
{
#define d_TimeOutMs 100
char l_cTxCommand[] = "Get Results\r\n";
size_t l_iNumBytesWriten;
printf("nrf_serial_init OK-%d\r\n", ret);
while(1)
{
vTaskDelay( pdMS_TO_TICKS(15*1000));
ret = nrf_serial_write(&serial_uart, l_cTxCommand, strlen(l_cTxCommand),
&l_iNumBytesWriten, NRF_ERROR_TIMEOUT );
if (ret != NRF_SUCCESS)
{
printf("nrf_serial_write FAIL-%d\r\n", ret);
//return(e_Status_Fail);
}
else
{
printf("nrf_serial_write OK. Bytes writen-%d\r\n", l_iNumBytesWriten);
//return(e_Status_OK);
}
}
}
}
And these are the results:
Start UV calibration
nrf_serial_init OK-0
Start Consol
nrf_serial_write OK. Bytes writen-13
nrf_serial_write FAIL-8
nrf_serial_write FAIL-8nrf_serial_write FAIL-8
nrf_serial_write FAIL-8
It seems to me that the problem is with the creation of the timer.
What shell I do to make it to work?
Thanks
Arik