Hi,
i'm actually working for interface the nRF52 with the STM32. Actually i completed the part where the STM32 send some data and the nRF52 recive it.
Now i need to do the same thing but with the nRF52 that send the data. I put an oscilloscope to see the data and nothing seems to happen. I'm not really understanding what can be the mistake.
Here's my code for set the uart:
void USART_Set(){
uint32_t err_code;
nrf_gpio_cfg_input(UART_RX_PIN, NRF_GPIO_PIN_PULLUP);
nrf_gpio_cfg_output(UART_TX_PIN);
const app_uart_comm_params_t comm_params =
{
UART_RX_PIN,
UART_TX_PIN,
RTS_PIN_NUMBER,
CTS_PIN_NUMBER,
APP_UART_FLOW_CONTROL_DISABLED,
false,
UART_BAUDRATE_BAUDRATE_Baud9600
};
APP_UART_FIFO_INIT(&comm_params,
UART_RX_BUF_SIZE,
UART_TX_BUF_SIZE,
uart_evt_callback,
APP_IRQ_PRIORITY_HIGHEST,
err_code);
APP_ERROR_CHECK(err_code);
}
#define UART_TX_PIN 9 //31 #define UART_RX_PIN 11 //30 #define UART_CTS_PIN 7 #define UART_RTS_PIN 8
Then i do:
int main(void)
{
uint32_t err_code;
timers_init();
...
advertising_start(erase_bonds);
USART_Set();
tx_enable = 1;
err_code = app_uart_put(0xAA);
APP_ERROR_CHECK(err_code);
// Enter main loop.
while(1){
...
}
}
and inside the handler:
void uart_evt_callback(app_uart_evt_t * p_event)
{
uint32_t err_code;
if (p_event->evt_type == APP_UART_FIFO_ERROR || p_event->evt_type == APP_UART_COMMUNICATION_ERROR)
{
err_code = app_uart_flush();
APP_ERROR_CHECK(err_code);
}
//se non ci sono dati nella seriale e l'invio e' attivo
if(p_event ->evt_type == APP_UART_TX_EMPTY && tx_enable){
err_code = app_uart_put(value_R[counter]);
APP_ERROR_CHECK(err_code);
counter++;
if(counter > 1){
counter = 0;
tx_enable = 1;
}
}
if(p_event ->evt_type == APP_UART_DATA_READY){
...
}
}
With the debugger i've seen that err_code is 0 after uart_put. Sometimes happen to go in the part of the FIFO_ERROR and stuff but not usually.
Thanks for the help