Hi Every one,
I am trying to use two uart's communications concurrently in nrf51422, in my code i am running timer of one second.
Every one second in timer routine trying to shift UART pins by using app_uart_close(); and uart_init(); functions with new pin set of RX & TX.
while it leaving Interrupt routine again initializing with older UART pins.
i got a problem with UART communication after switching to second UART it unable to send proper values.
(it is sending only first character of second UART).
please help me is that is correct way to do shifting of UART communication pins?
please follow my attached code for better understanding.
/* timer handler for Every one second */
static void Energy_meter_handler(void * p_context)
{
uint32_t err_code;
nrf_delay_ms(5);
printf("UART 1 closed");
err_code=app_uart_close(); // Closing main UART
nrf_delay_ms(25);
Uart_Init1(); // initializing with new UART pins
nrf_delay_ms(25);
printf("UART 2 opened");
/* operations on second UART */
if(!ENG_SET)
{
Set_Energy_meter_Reg();
}
Read_Values_from_Energy_Meter();
Energy_Meter=false;
printf("UART 2 closed");
/**************************************************/
err_code=app_uart_close(); // Closing Second UART
nrf_delay_ms(25);
uart_init(); // re-initializing with previous UART
nrf_delay_ms(25);
printf("UART 1 opened");
Calculate_values();
printf("\n\rVrms : %f\tIrms : %f\n",VOL_RMS,CUR_RMS);
nrf_delay_ms(5);
}
Thanks in Advance.
