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

printf wasn't working.(updated July,1,2016)

Hello. I use nRF52 , PCA10040 , S132 & SDK 11.

I want to send data what get through UART to nRF52 from a peripheral, to PC by UART. Due to, I made this program from example -> peripheral -> uart. But printf() was not working. I think so because Tera Term(Terminal app) in PC showed nothing.

Where is mistake by me? My program is following. And this figure is flow what I want to nRF52 do. I want to nRF52 do this flow.

void uart_init_r(){

uint32_t err_code;
const app_uart_comm_params_t comm_params =
  {
      30, //UART Device's RX
      31, //UART Device's TX,
      RTS_PIN_NUMBER, //7
      CTS_PIN_NUMBER, //5
      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_error_handle,
                     APP_IRQ_PRIORITY_LOW,
                     err_code);

APP_ERROR_CHECK(err_code);

}

void uart_init_w(){

uint32_t err_code;
const app_uart_comm_params_t comm_params =
  {
      RX_PIN_NUMBER, //8
      TX_PIN_NUMBER,  //6
      RTS_PIN_NUMBER,  //7
      CTS_PIN_NUMBER,  //5
      APP_UART_FLOW_CONTROL_ENABLED,
      false,
      UART_BAUDRATE_BAUDRATE_Baud9600
  };

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

APP_ERROR_CHECK(err_code);

}

int main(void) { LEDS_CONFIGURE(LEDS_MASK); LEDS_ON(LEDS_MASK); uint32_t count = 0; uint8_t led_list[3]={18,19,20}; uint8_t cr; gpio_init();

    uart_init_w();
    printf("\n\rStart#1 \n\r");	
uart_init_r();
    printf("\n\rStart#2 \n\r");
  uint8_t s[100];
  uint8_t len = 0;
while (true)
{
    while(app_uart_get(&cr) != NRF_SUCCESS);

LEDS_INVERT(1<<led_list[count&0x03]);
count++;

if (cr == '$'){
	LEDS_OFF(1<< 17);
	uart_init_w();
        	printf("%s\n\r",s);
	uart_init_r();
	LEDS_ON(1<<17);
    }
else{
	if(len < 99){
		LEDS_OFF(1<< 17);
		s[len] = cr;
	    	len++;
	}
	else{
		len = 0;
	}
 }
			
}

}

Parents Reply Children
No Data
Related